Skip to content

Commit

Permalink
Fixes after review
Browse files Browse the repository at this point in the history
* remove unknown comments
* handle error from getTargetAzureSubscription
* improve error text if cloud env value not known (until preferred logging solution)
  • Loading branch information
tjololo committed Dec 27, 2024
1 parent a8366d7 commit 9ce1c1c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
15 changes: 13 additions & 2 deletions modules/azure/client_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,9 @@ func getBaseURI() (string, error) {
// getArmAppContainersClientFactory gets an arm app containers client factory
func getArmAppContainersClientFactory(subscriptionID string) (*armappcontainers.ClientFactory, error) {
targetSubscriptionID, err := getTargetAzureSubscription(subscriptionID)
if err != nil {
return nil, err
}
clientCloudConfig, err := getClientCloudConfig()
if err != nil {
return nil, err
Expand Down Expand Up @@ -1048,7 +1051,15 @@ func getClientCloudConfig() (cloud.Configuration, error) {
},
},
}
return c, err
return c, nil
default:
return cloud.Configuration{},
fmt.Errorf("no cloud environment matching the name: %s. "+
"Available values are: "+
"AzurePublicCloud (default), "+
"AzureUSGovernmentCloud, "+
"AzureChinaCloud or "+
"AzureStackCloud",
envName)
}
return cloud.Configuration{}, fmt.Errorf("no cloud environment matching the name: %s", envName)
}
5 changes: 0 additions & 5 deletions test/azure/terraform_azure_container_apps_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ func TestTerraformAzureContainerAppExample(t *testing.T) {
subscriptionID := ""
uniquePostfix := strings.ToLower(random.UniqueId())

// website::tag::1:: Configure Terraform setting up a path to Terraform code.
terraformOptions := &terraform.Options{
TerraformBinary: "",
// The path to where our Terraform code is located
Expand All @@ -32,19 +31,15 @@ func TestTerraformAzureContainerAppExample(t *testing.T) {
},
}

// website::tag::4:: At the end of the test, run `terraform destroy` to clean up any resources that were created
defer terraform.Destroy(t, terraformOptions)

// website::tag::2:: Run `terraform init` and `terraform apply`. Fail the test if there are any errors.
terraform.InitAndApply(t, terraformOptions)

// website::tag::3:: Run `terraform output` to get the values of output variables
resourceGroupName := terraform.Output(t, terraformOptions, "resource_group_name")
envName := terraform.Output(t, terraformOptions, "container_app_env_name")
containerAppName := terraform.Output(t, terraformOptions, "container_app_name")
containerAppJobName := terraform.Output(t, terraformOptions, "container_app_job_name")

// website::tag::4:: Get Azure Container app details and assert them against the terraform output
// NOTE: the value of subscriptionID can be left blank, it will be replaced by the value
// of the environment variable ARM_SUBSCRIPTION_ID

Expand Down

0 comments on commit 9ce1c1c

Please sign in to comment.