Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use d.Get to set PRIVATE_EMPTY of azurerm_container_group #8151

Merged
merged 4 commits into from
Aug 24, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1152,10 +1152,9 @@ func flattenContainerEnvironmentVariables(input *[]containerinstance.Environment
if isSecure {
for _, envVar := range *input {
if envVar.Name != nil && envVar.Value == nil {
if v, ok := d.GetOk(fmt.Sprintf("container.%d.secure_environment_variables.%s", oldContainerIndex, *envVar.Name)); ok {
log.Printf("[DEBUG] SECURE : Name: %s - Value: %s", *envVar.Name, v.(string))
output[*envVar.Name] = v.(string)
}
envVarValue := d.Get(fmt.Sprintf("container.%d.secure_environment_variables.%s", oldContainerIndex, *envVar.Name))
log.Printf("[DEBUG] SECURE : Name: %s - Value: %s", *envVar.Name, envVarValue)
tombuildsstuff marked this conversation as resolved.
Show resolved Hide resolved
output[*envVar.Name] = envVarValue
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,27 @@ func TestAccAzureRMContainerGroup_windowsComplete(t *testing.T) {
})
}

func TestAccAzureRMContainerGroup_withPrivateEmpty(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_container_group", "test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
Providers: acceptance.SupportedProviders,
CheckDestroy: testCheckAzureRMContainerGroupDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMContainerGroup_withPrivateEmpty(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMContainerGroupExists(data.ResourceName),
),
},
data.ImportStep(
"container.0.secure_environment_variables.PRIVATE_VALUE",
),
},
})
}

func testAccAzureRMContainerGroup_SystemAssignedIdentity(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down Expand Up @@ -1239,3 +1260,47 @@ func testCheckAzureRMContainerGroupDestroy(s *terraform.State) error {

return nil
}

func testAccAzureRMContainerGroup_withPrivateEmpty(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}

resource "azurerm_resource_group" "test" {
name = "acctestRG-containergroup-%d"
location = "%s"
}

resource "azurerm_container_group" "test" {
name = "acctestcontainergroup-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
ip_address_type = "public"
dns_name_label = "jerome-aci-label"
os_type = "Linux"

container {
name = "hello-world"
image = "microsoft/aci-helloworld:latest"
cpu = "0.5"
memory = "1.5"

ports {
port = 8000
protocol = "TCP"
}

secure_environment_variables = {
PRIVATE_EMPTY = ""
PRIVATE_VALUE = "test"
}

environment_variables = {
PUBLIC_EMPTY = ""
PUBLIC_VALUE = "test"
}
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}