Update tests for Azure Shared Image Gallery
This commit is contained in:
parent
b6bb5d4b4d
commit
5373b8586d
|
@ -79,13 +79,14 @@ type Config struct {
|
||||||
CaptureNamePrefix string `mapstructure:"capture_name_prefix"`
|
CaptureNamePrefix string `mapstructure:"capture_name_prefix"`
|
||||||
CaptureContainerName string `mapstructure:"capture_container_name"`
|
CaptureContainerName string `mapstructure:"capture_container_name"`
|
||||||
|
|
||||||
// Compute
|
// Shared Gallery
|
||||||
SharedGallerySubscription string `mapstructure:"shared_gallery_subscription"`
|
SharedGallerySubscription string `mapstructure:"shared_gallery_subscription"`
|
||||||
SharedGalleryResourceGroup string `mapstructure:"shared_gallery_resource_group"`
|
SharedGalleryResourceGroup string `mapstructure:"shared_gallery_resource_group"`
|
||||||
SharedGalleryName string `mapstructure:"shared_gallery_name"`
|
SharedGalleryName string `mapstructure:"shared_gallery_name"`
|
||||||
SharedGalleryImageName string `mapstructure:"shared_gallery_image_name"`
|
SharedGalleryImageName string `mapstructure:"shared_gallery_image_name"`
|
||||||
SharedGalleryImageVersion string `mapstructure:"shared_gallery_image_version"`
|
SharedGalleryImageVersion string `mapstructure:"shared_gallery_image_version"`
|
||||||
|
|
||||||
|
// Compute
|
||||||
ImagePublisher string `mapstructure:"image_publisher"`
|
ImagePublisher string `mapstructure:"image_publisher"`
|
||||||
ImageOffer string `mapstructure:"image_offer"`
|
ImageOffer string `mapstructure:"image_offer"`
|
||||||
ImageSku string `mapstructure:"image_sku"`
|
ImageSku string `mapstructure:"image_sku"`
|
||||||
|
@ -601,6 +602,12 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) {
|
||||||
if c.SharedGalleryImageName == "" {
|
if c.SharedGalleryImageName == "" {
|
||||||
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A shared_gallery_image_name must be specified"))
|
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A shared_gallery_image_name must be specified"))
|
||||||
}
|
}
|
||||||
|
if c.CaptureContainerName != "" {
|
||||||
|
errs = packer.MultiErrorAppend(errs, fmt.Errorf("VHD Target [capture_container_name] is not supported when using Shared Image Gallery as source. Use managed_image_resource_group_name instead."))
|
||||||
|
}
|
||||||
|
if c.CaptureNamePrefix != "" {
|
||||||
|
errs = packer.MultiErrorAppend(errs, fmt.Errorf("VHD Target [capture_name_prefix] is not supported when using Shared Image Gallery as source. Use managed_image_name instead."))
|
||||||
|
}
|
||||||
} else if c.ImageUrl == "" && c.CustomManagedImageName == "" {
|
} else if c.ImageUrl == "" && c.CustomManagedImageName == "" {
|
||||||
if c.ImagePublisher == "" {
|
if c.ImagePublisher == "" {
|
||||||
errs = packer.MultiErrorAppend(errs, fmt.Errorf("An image_publisher must be specified"))
|
errs = packer.MultiErrorAppend(errs, fmt.Errorf("An image_publisher must be specified"))
|
||||||
|
|
|
@ -1294,6 +1294,49 @@ func TestConfigShouldAllowAsyncResourceGroupOverrideBadValue(t *testing.T) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
func TestConfigShouldAllowSharedImageGalleryOptions(t *testing.T) {
|
||||||
|
config := map[string]interface{}{
|
||||||
|
"location": "ignore",
|
||||||
|
"subscription_id": "ignore",
|
||||||
|
"os_type": "linux",
|
||||||
|
"shared_gallery_subscription": "ignore",
|
||||||
|
"shared_gallery_resource_group": "ignore",
|
||||||
|
"shared_gallery_resource_group": "ignore",
|
||||||
|
"shared_gallery_name": "ignore",
|
||||||
|
"shared_gallery_image_name": "ignore",
|
||||||
|
"shared_gallery_image_version": "ignore",
|
||||||
|
}
|
||||||
|
|
||||||
|
c, _, err := newConfig(config, getPackerConfiguration())
|
||||||
|
if err == nil {
|
||||||
|
t.Errorf("expected config to accept Shared Image Gallery options", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestConfigShouldRejectSharedImageGalleryWithVhdTarget(t *testing.T) {
|
||||||
|
config := map[string]interface{}{
|
||||||
|
"location": "ignore",
|
||||||
|
"subscription_id": "ignore",
|
||||||
|
"os_type": "linux",
|
||||||
|
"shared_gallery_subscription": "ignore",
|
||||||
|
"shared_gallery_resource_group": "ignore",
|
||||||
|
"shared_gallery_resource_group": "ignore",
|
||||||
|
"shared_gallery_name": "ignore",
|
||||||
|
"shared_gallery_image_name": "ignore",
|
||||||
|
"shared_gallery_image_version": "ignore",
|
||||||
|
"resource_group_name": "ignore",
|
||||||
|
"storage_account": "ignore",
|
||||||
|
"capture_container_name": "ignore",
|
||||||
|
"capture_name_prefix": "ignore",
|
||||||
|
}
|
||||||
|
|
||||||
|
c, _, err := newConfig(config, getPackerConfiguration())
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("expected an error if Shared Image Gallery source is used with VHD target", err)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getArmBuilderConfiguration() map[string]string {
|
func getArmBuilderConfiguration() map[string]string {
|
||||||
|
|
Loading…
Reference in New Issue