Skip to content

Commit 27e9672

Browse files
committed
Test network policy config addon.
1 parent 0e24782 commit 27e9672

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

google/resource_container_cluster_test.go

+31-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,16 @@ func TestAccContainerCluster_withNetworkPolicyEnabled(t *testing.T) {
146146
),
147147
},
148148
{
149-
Config: testAccContainerCluster_withNetworkPolicyDisabled(clusterName),
149+
Config: testAccContainerCluster_withNetworkPolicyConfigDisabled(clusterName),
150+
Check: resource.ComposeTestCheckFunc(
151+
testAccCheckContainerCluster(
152+
"google_container_cluster.with_network_policy_enabled"),
153+
resource.TestCheckResourceAttr("google_container_cluster.with_network_policy_enabled",
154+
"addons_config.0.network_policy_config.0.disabled", "true"),
155+
),
156+
},
157+
{
158+
Config: testAccContainerCluster_withNetworkPolicyConfigDisabled(clusterName),
150159
PlanOnly: true,
151160
ExpectNonEmptyPlan: false,
152161
},
@@ -1121,6 +1130,11 @@ resource "google_container_cluster" "with_network_policy_enabled" {
11211130
enabled = true
11221131
provider = "CALICO"
11231132
}
1133+
addons_config {
1134+
network_policy_config {
1135+
disabled = false
1136+
}
1137+
}
11241138
}`, clusterName)
11251139
}
11261140

@@ -1144,6 +1158,22 @@ resource "google_container_cluster" "with_network_policy_enabled" {
11441158
}`, clusterName)
11451159
}
11461160

1161+
func testAccContainerCluster_withNetworkPolicyConfigDisabled(clusterName string) string {
1162+
return fmt.Sprintf(`
1163+
resource "google_container_cluster" "with_network_policy_enabled" {
1164+
name = "%s"
1165+
zone = "us-central1-a"
1166+
initial_node_count = 1
1167+
1168+
network_policy = {}
1169+
addons_config {
1170+
network_policy_config {
1171+
disabled = true
1172+
}
1173+
}
1174+
}`, clusterName)
1175+
}
1176+
11471177
func testAccContainerCluster_withMasterAuthorizedNetworksConfig(clusterName string, cidrs []string) string {
11481178

11491179
cidrBlocks := ""

0 commit comments

Comments
 (0)