Skip to content

Commit e1c20bd

Browse files
authored
Merge pull request #11 from Azure/pr-paas-extensions
PaaS extensions are not JSON
2 parents 3fb2786 + 9ddfa60 commit e1c20bd

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ var (
7272
flJSON = cli.BoolFlag{
7373
Name: "json",
7474
Usage: "Print output as JSON"}
75+
flIsXMLExtension = cli.BoolFlag{
76+
Name: "is-xml-extension",
77+
Usage: "Set if this is an XML extension, i.e. PaaS"}
7578
)
7679

7780
func main() {
@@ -139,7 +142,7 @@ func main() {
139142
Action: replicationStatus},
140143
{Name: "unpublish-version",
141144
Usage: "Marks the specified version of the extension internal. Does not delete.",
142-
Flags: []cli.Flag{flMgtURL, flSubsID, flSubsCert, flNamespace, flName, flVersion},
145+
Flags: []cli.Flag{flMgtURL, flSubsID, flSubsCert, flNamespace, flName, flVersion, flIsXMLExtension},
143146
Action: unpublishVersion},
144147
{Name: "delete-version",
145148
Usage: "Deletes the extension version. It should be unpublished first.",

unpublish.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,24 @@ func unpublishVersion(c *cli.Context) {
1616
Name: checkFlag(c, flName.Name),
1717
Version: checkFlag(c, flVersion.Name)}
1818

19-
unpublishManifestXML := `<?xml version="1.0" encoding="utf-8" ?>
19+
isXMLExtension := c.Bool(flIsXMLExtension.Name)
20+
buf := bytes.NewBufferString(`<?xml version="1.0" encoding="utf-8" ?>
2021
<ExtensionImage xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
2122
<!-- WARNING: Ordering of fields matter in this file. -->
2223
<ProviderNameSpace>{{.Namespace}}</ProviderNameSpace>
2324
<Type>{{.Name}}</Type>
2425
<Version>{{.Version}}</Version>
2526
<IsInternalExtension>true</IsInternalExtension>
26-
<IsJsonExtension>true</IsJsonExtension>
27-
</ExtensionImage>`
28-
tpl, err := template.New("unregisterManifest").Parse(unpublishManifestXML)
27+
`)
28+
29+
// All extension should be a JSON extension. The biggest offenders are
30+
// PaaS extensions.
31+
if !isXMLExtension {
32+
buf.WriteString("<IsJsonExtension>true</IsJsonExtension>")
33+
}
34+
35+
buf.WriteString("</ExtensionImage>")
36+
tpl, err := template.New("unregisterManifest").Parse(buf.String())
2937
if err != nil {
3038
log.Fatalf("template parse error: %v", err)
3139
}

0 commit comments

Comments
 (0)