Skip to content

Commit

Permalink
Support for XML extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
boumenot committed Jun 15, 2017
1 parent 8cf99ee commit 6884511
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 6884511

Please sign in to comment.