azure-arm: Validate that resource_group_name is being set

This commit is contained in:
Paul Meyer 2016-06-09 01:00:23 -07:00
parent 658de07e24
commit 0c79293dde
2 changed files with 17 additions and 5 deletions

View File

@ -455,6 +455,9 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) {
if c.StorageAccount == "" { if c.StorageAccount == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A storage_account must be specified")) errs = packer.MultiErrorAppend(errs, fmt.Errorf("A storage_account must be specified"))
} }
if c.ResourceGroupName == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A resource_group_name must be specified"))
}
///////////////////////////////////////////// /////////////////////////////////////////////
// OS // OS

View File

@ -25,6 +25,7 @@ var requiredConfigValues = []string{
"location", "location",
"os_type", "os_type",
"storage_account", "storage_account",
"resource_group_name",
"subscription_id", "subscription_id",
"tenant_id", "tenant_id",
} }
@ -121,6 +122,7 @@ func TestConfigInstantiatesCorrectAzureEnvironment(t *testing.T) {
"image_sku": "ignore", "image_sku": "ignore",
"location": "ignore", "location": "ignore",
"storage_account": "ignore", "storage_account": "ignore",
"resource_group_name": "ignore",
"subscription_id": "ignore", "subscription_id": "ignore",
"os_type": constants.Target_Linux, "os_type": constants.Target_Linux,
"communicator": "none", "communicator": "none",
@ -151,7 +153,10 @@ func TestConfigInstantiatesCorrectAzureEnvironment(t *testing.T) {
for _, x := range table { for _, x := range table {
config["cloud_environment_name"] = x.name config["cloud_environment_name"] = x.name
c, _, _ := newConfig(config, packerConfiguration) c, _, err := newConfig(config, packerConfiguration)
if err != nil {
t.Fatal(err)
}
if c.cloudEnvironment == nil || c.cloudEnvironment.Name != x.environmentName { if c.cloudEnvironment == nil || c.cloudEnvironment.Name != x.environmentName {
t.Errorf("Expected 'cloudEnvironment' to be set to '%s', but got '%s'.", x.environmentName, c.cloudEnvironment) t.Errorf("Expected 'cloudEnvironment' to be set to '%s', but got '%s'.", x.environmentName, c.cloudEnvironment)
@ -354,6 +359,7 @@ func TestUserDeviceLoginIsEnabledForLinux(t *testing.T) {
"image_sku": "ignore", "image_sku": "ignore",
"location": "ignore", "location": "ignore",
"storage_account": "ignore", "storage_account": "ignore",
"resource_group_name": "ignore",
"subscription_id": "ignore", "subscription_id": "ignore",
"os_type": constants.Target_Linux, "os_type": constants.Target_Linux,
"communicator": "none", "communicator": "none",
@ -374,6 +380,7 @@ func TestUseDeviceLoginIsDisabledForWindows(t *testing.T) {
"image_sku": "ignore", "image_sku": "ignore",
"location": "ignore", "location": "ignore",
"storage_account": "ignore", "storage_account": "ignore",
"resource_group_name": "ignore",
"subscription_id": "ignore", "subscription_id": "ignore",
"os_type": constants.Target_Windows, "os_type": constants.Target_Windows,
"communicator": "none", "communicator": "none",
@ -408,6 +415,7 @@ func TestConfigShouldRejectMalformedCaptureNamePrefix(t *testing.T) {
"image_sku": "ignore", "image_sku": "ignore",
"location": "ignore", "location": "ignore",
"storage_account": "ignore", "storage_account": "ignore",
"resource_group_name": "ignore",
"subscription_id": "ignore", "subscription_id": "ignore",
// Does not matter for this test case, just pick one. // Does not matter for this test case, just pick one.
"os_type": constants.Target_Linux, "os_type": constants.Target_Linux,
@ -457,6 +465,7 @@ func TestConfigShouldRejectMalformedCaptureContainerName(t *testing.T) {
"image_sku": "ignore", "image_sku": "ignore",
"location": "ignore", "location": "ignore",
"storage_account": "ignore", "storage_account": "ignore",
"resource_group_name": "ignore",
"subscription_id": "ignore", "subscription_id": "ignore",
// Does not matter for this test case, just pick one. // Does not matter for this test case, just pick one.
"os_type": constants.Target_Linux, "os_type": constants.Target_Linux,