try to fix 201-vmss-packer-jumpbox

This commit is contained in:
hezijie 2024-09-14 11:27:16 +08:00 committed by lonegunmanb
parent 8e98c2eb21
commit d93a6bba20

View File

@ -115,20 +115,16 @@ func test201VmssPackerJumpbox(t *testing.T) {
packerVars := map[string]string{ packerVars := map[string]string{
"image_resource_group_name": imageResourceGroupName, "image_resource_group_name": imageResourceGroupName,
} }
useMsi := false
if clientId := os.Getenv("ARM_CLIENT_ID"); clientId != "" { if clientId := os.Getenv("ARM_CLIENT_ID"); clientId != "" {
packerVars["client_id"] = clientId packerVars["client_id"] = clientId
} }
if os.Getenv("MSI_ID") != "" {
useMsi = true
}
if clientSecret := os.Getenv("ARM_CLIENT_SECRET"); clientSecret != "" { if clientSecret := os.Getenv("ARM_CLIENT_SECRET"); clientSecret != "" {
packerVars["client_secret"] = clientSecret packerVars["client_secret"] = clientSecret
} }
if subscriptionId := os.Getenv("ARM_SUBSCRIPTION_ID"); subscriptionId != "" { if subscriptionId := os.Getenv("ARM_SUBSCRIPTION_ID"); subscriptionId != "" {
packerVars["subscription_id"] = subscriptionId packerVars["subscription_id"] = subscriptionId
} }
if tenantId := os.Getenv("ARM_TENANT_ID"); !useMsi && tenantId != "" { if tenantId := os.Getenv("ARM_TENANT_ID"); tenantId != "" {
packerVars["tenant_id"] = tenantId packerVars["tenant_id"] = tenantId
} }
patches := gomonkey.ApplyFunc(shell.RunCommandAndGetOutputE, func(t terratest.TestingT, command shell.Command) (string, error) { patches := gomonkey.ApplyFunc(shell.RunCommandAndGetOutputE, func(t terratest.TestingT, command shell.Command) (string, error) {