Skip to content

Commit

Permalink
Merge pull request #5 from hglkrijger/master
Browse files Browse the repository at this point in the history
skip the IsInternalExtension update for the vm agent namespace
  • Loading branch information
boumenot authored Jan 20, 2017
2 parents 5144ac2 + b7481df commit cf705f5
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions promote.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,24 @@ func mkRegionElement(regions ...string) string {
}

// updateManifestRegions makes an in-memory update to the <!--%REGIONS%-->
// placeholder string in the manifest XML for further usage and replaces
// <IsInternalExtension>true... with ...false.
// placeholder string in the manifest XML for further usage, and
// sets <IsInternalExtension> according to whether the package
// should remain internal (vm agent) or not (extensions)
func updateManifestRegions(manifestPath string, regionsXMLElement string) ([]byte, error) {
b, err := ioutil.ReadFile(manifestPath)
if err != nil {
return nil, fmt.Errorf("Error reading manifest: %v", err)
}

// I know I can do better than this, but will I?
// todo: improve this
b = bytes.Replace(b, []byte(`<!--%REGIONS%-->`), []byte(regionsXMLElement), 1)
return bytes.Replace(b, []byte(`<IsInternalExtension>true`), []byte(`<IsInternalExtension>false`), 1), nil

updateInternal := !bytes.Contains(b, []byte(`<ProviderNameSpace>Microsoft.OSTCLinuxAgent</ProviderNameSpace>`))
if updateInternal {
b = bytes.Replace(b, []byte(`<IsInternalExtension>true`), []byte(`<IsInternalExtension>false`), 1)
} else {
log.Debug("VM agent namespace detected, IsInternalExtension ignored")
}

return b, err
}

0 comments on commit cf705f5

Please sign in to comment.