normalize replication regions
This commit is contained in:
parent
59a0f7f6e6
commit
f1f93f0665
|
@ -141,7 +141,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate that Shared Gallery Image exists before publishing to SIG
|
// validate that Shared Gallery Image exists before publishing to SIG
|
||||||
if b.config.SharedGalleryDestination.SigDestinationGalleryName != "" {
|
if b.config.isManagedImage() && b.config.SharedGalleryDestination.SigDestinationGalleryName != "" {
|
||||||
_, err = azureClient.GalleryImagesClient.Get(ctx, b.config.SharedGalleryDestination.SigDestinationResourceGroup, b.config.SharedGalleryDestination.SigDestinationGalleryName, b.config.SharedGalleryDestination.SigDestinationImageName)
|
_, err = azureClient.GalleryImagesClient.Get(ctx, b.config.SharedGalleryDestination.SigDestinationResourceGroup, b.config.SharedGalleryDestination.SigDestinationGalleryName, b.config.SharedGalleryDestination.SigDestinationImageName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("the Shared Gallery Image to which to publish the managed image version to does not exists in the resource group %s", b.config.SharedGalleryDestination.SigDestinationResourceGroup)
|
return nil, fmt.Errorf("the Shared Gallery Image to which to publish the managed image version to does not exists in the resource group %s", b.config.SharedGalleryDestination.SigDestinationResourceGroup)
|
||||||
|
@ -428,9 +428,15 @@ func getObjectIdFromToken(ui packer.Ui, token *adal.ServicePrincipalToken) strin
|
||||||
|
|
||||||
func verifyAndUpdateReplicationRegions(regions []string, mustHaveRegion string) []string {
|
func verifyAndUpdateReplicationRegions(regions []string, mustHaveRegion string) []string {
|
||||||
for _, region := range regions {
|
for _, region := range regions {
|
||||||
if strings.EqualFold(region, mustHaveRegion) {
|
// change region to lower-case and strip spaces
|
||||||
|
normalizedRegion := normalizeAzureRegion(region)
|
||||||
|
if strings.EqualFold(normalizedRegion, mustHaveRegion) {
|
||||||
return regions
|
return regions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return append(regions, mustHaveRegion)
|
return append(regions, mustHaveRegion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func normalizeAzureRegion(name string) string {
|
||||||
|
return strings.ToLower(strings.Replace(name, " ", "", -1))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue