@@ -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)
5657func 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