Skip to content

Commit cf705f5

Browse files
authored
Merge pull request #5 from hglkrijger/master
skip the IsInternalExtension update for the vm agent namespace
2 parents 5144ac2 + b7481df commit cf705f5

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

promote.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,24 @@ func mkRegionElement(regions ...string) string {
5151
}
5252

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

62-
// I know I can do better than this, but will I?
63+
// todo: improve this
6364
b = bytes.Replace(b, []byte(`<!--%REGIONS%-->`), []byte(regionsXMLElement), 1)
64-
return bytes.Replace(b, []byte(`<IsInternalExtension>true`), []byte(`<IsInternalExtension>false`), 1), nil
65+
66+
updateInternal := !bytes.Contains(b, []byte(`<ProviderNameSpace>Microsoft.OSTCLinuxAgent</ProviderNameSpace>`))
67+
if updateInternal {
68+
b = bytes.Replace(b, []byte(`<IsInternalExtension>true`), []byte(`<IsInternalExtension>false`), 1)
69+
} else {
70+
log.Debug("VM agent namespace detected, IsInternalExtension ignored")
71+
}
72+
73+
return b, err
6574
}

0 commit comments

Comments
 (0)