Skip to content

Commit

Permalink
Merge pull request #11 from Azure/pr-paas-extensions
Browse files Browse the repository at this point in the history
PaaS extensions are not JSON
  • Loading branch information
boumenot authored Jun 23, 2017
2 parents 3fb2786 + 9ddfa60 commit e1c20bd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ var (
flJSON = cli.BoolFlag{
Name: "json",
Usage: "Print output as JSON"}
flIsXMLExtension = cli.BoolFlag{
Name: "is-xml-extension",
Usage: "Set if this is an XML extension, i.e. PaaS"}
)

func main() {
Expand Down Expand Up @@ -139,7 +142,7 @@ func main() {
Action: replicationStatus},
{Name: "unpublish-version",
Usage: "Marks the specified version of the extension internal. Does not delete.",
Flags: []cli.Flag{flMgtURL, flSubsID, flSubsCert, flNamespace, flName, flVersion},
Flags: []cli.Flag{flMgtURL, flSubsID, flSubsCert, flNamespace, flName, flVersion, flIsXMLExtension},
Action: unpublishVersion},
{Name: "delete-version",
Usage: "Deletes the extension version. It should be unpublished first.",
Expand Down
16 changes: 12 additions & 4 deletions unpublish.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,24 @@ func unpublishVersion(c *cli.Context) {
Name: checkFlag(c, flName.Name),
Version: checkFlag(c, flVersion.Name)}

unpublishManifestXML := `<?xml version="1.0" encoding="utf-8" ?>
isXMLExtension := c.Bool(flIsXMLExtension.Name)
buf := bytes.NewBufferString(`<?xml version="1.0" encoding="utf-8" ?>
<ExtensionImage xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<!-- WARNING: Ordering of fields matter in this file. -->
<ProviderNameSpace>{{.Namespace}}</ProviderNameSpace>
<Type>{{.Name}}</Type>
<Version>{{.Version}}</Version>
<IsInternalExtension>true</IsInternalExtension>
<IsJsonExtension>true</IsJsonExtension>
</ExtensionImage>`
tpl, err := template.New("unregisterManifest").Parse(unpublishManifestXML)
`)

// All extension should be a JSON extension. The biggest offenders are
// PaaS extensions.
if !isXMLExtension {
buf.WriteString("<IsJsonExtension>true</IsJsonExtension>")
}

buf.WriteString("</ExtensionImage>")
tpl, err := template.New("unregisterManifest").Parse(buf.String())
if err != nil {
log.Fatalf("template parse error: %v", err)
}
Expand Down

0 comments on commit e1c20bd

Please sign in to comment.