Skip to content

Commit

Permalink
allow master authorized networks config to be removed
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
megan07 authored and modular-magician committed Sep 12, 2019
1 parent 65f26df commit 772b747
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
6 changes: 4 additions & 2 deletions google/resource_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1771,7 +1771,9 @@ func expandMasterAuth(configured interface{}) *containerBeta.MasterAuth {
func expandMasterAuthorizedNetworksConfig(configured interface{}) *containerBeta.MasterAuthorizedNetworksConfig {
l := configured.([]interface{})
if len(l) == 0 {
return nil
return &containerBeta.MasterAuthorizedNetworksConfig{
Enabled: false,
}
}
result := &containerBeta.MasterAuthorizedNetworksConfig{
Enabled: true,
Expand Down Expand Up @@ -1990,7 +1992,7 @@ func flattenMasterAuth(ma *containerBeta.MasterAuth) []map[string]interface{} {
}

func flattenMasterAuthorizedNetworksConfig(c *containerBeta.MasterAuthorizedNetworksConfig) []map[string]interface{} {
if c == nil {
if c == nil || !c.Enabled {
return nil
}
result := make(map[string]interface{})
Expand Down
21 changes: 20 additions & 1 deletion google/resource_container_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,15 @@ func TestAccContainerCluster_withMasterAuthorizedNetworksConfig(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccContainerCluster_removeMasterAuthorizedNetworksConfig(clusterName),
},
{
ResourceName: "google_container_cluster.with_master_authorized_networks",
ImportStateIdPrefix: "us-central1-a/",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand Down Expand Up @@ -1463,7 +1472,7 @@ func testAccContainerCluster_withMasterAuthorizedNetworksConfig(clusterName stri
return fmt.Sprintf(`
resource "google_container_cluster" "with_master_authorized_networks" {
name = "%s"
zone = "us-central1-a"
location = "us-central1-a"
initial_node_count = 1
master_authorized_networks_config {
Expand All @@ -1472,6 +1481,16 @@ resource "google_container_cluster" "with_master_authorized_networks" {
}`, clusterName, cidrBlocks)
}

func testAccContainerCluster_removeMasterAuthorizedNetworksConfig(clusterName string) string {

return fmt.Sprintf(`
resource "google_container_cluster" "with_master_authorized_networks" {
name = "%s"
location = "us-central1-a"
initial_node_count = 1
}`, clusterName)
}

func testAccContainerCluster_regional(clusterName string) string {
return fmt.Sprintf(`
resource "google_container_cluster" "regional" {
Expand Down

0 comments on commit 772b747

Please sign in to comment.