Skip to content

Commit fbcfb40

Browse files
authored
fix allow_external_traffic not being settable if other dns_endpoint_config fields are set (GoogleCloudPlatform#17127)
1 parent 1d85583 commit fbcfb40

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

mmv1/third_party/terraform/services/container/resource_container_cluster.go.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6789,17 +6789,17 @@ func expandControlPlaneEndpointsConfig(d *schema.ResourceData) *container.Contro
67896789
dns := &container.DNSEndpointConfig{}
67906790
if v := d.Get("control_plane_endpoints_config.0.dns_endpoint_config.0.allow_external_traffic"); v != nil {
67916791
dns.AllowExternalTraffic = v.(bool)
6792-
dns.ForceSendFields = []string{"AllowExternalTraffic"}
6792+
dns.ForceSendFields = append(dns.ForceSendFields, "AllowExternalTraffic")
67936793
}
67946794

67956795
if v := d.Get("control_plane_endpoints_config.0.dns_endpoint_config.0.enable_k8s_tokens_via_dns"); v != nil {
67966796
dns.EnableK8sTokensViaDns = v.(bool)
6797-
dns.ForceSendFields = []string{"EnableK8sTokensViaDns"}
6797+
dns.ForceSendFields = append(dns.ForceSendFields, "EnableK8sTokensViaDns")
67986798
}
67996799

68006800
if v := d.Get("control_plane_endpoints_config.0.dns_endpoint_config.0.enable_k8s_certs_via_dns"); v != nil {
68016801
dns.EnableK8sCertsViaDns = v.(bool)
6802-
dns.ForceSendFields = []string{"EnableK8sCertsViaDns"}
6802+
dns.ForceSendFields = append(dns.ForceSendFields, "EnableK8sCertsViaDns")
68036803
}
68046804

68056805
ip := &container.IPEndpointsConfig{

mmv1/third_party/terraform/services/container/resource_container_cluster_test.go.tmpl

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16052,6 +16052,19 @@ func TestAccContainerCluster_withDnsEndpoint(t *testing.T) {
1605216052
ImportStateVerify: true,
1605316053
ImportStateVerifyIgnore: []string{"deletion_protection"},
1605416054
},
16055+
{
16056+
Config: testAccContainerCluster_withDnsEndpoint(clusterName, networkName, subnetworkName, false),
16057+
Check: resource.ComposeAggregateTestCheckFunc(
16058+
resource.TestCheckResourceAttrSet("google_container_cluster.primary", "control_plane_endpoints_config.0.dns_endpoint_config.0.endpoint"),
16059+
resource.TestCheckResourceAttr("google_container_cluster.primary", "control_plane_endpoints_config.0.dns_endpoint_config.0.allow_external_traffic", "false"),
16060+
),
16061+
},
16062+
{
16063+
ResourceName: "google_container_cluster.primary",
16064+
ImportState: true,
16065+
ImportStateVerify: true,
16066+
ImportStateVerifyIgnore: []string{"deletion_protection"},
16067+
},
1605516068
},
1605616069
})
1605716070
}
@@ -16068,9 +16081,11 @@ resource "google_container_cluster" "primary" {
1606816081
control_plane_endpoints_config {
1606916082
dns_endpoint_config {
1607016083
allow_external_traffic = %t
16084+
enable_k8s_tokens_via_dns = %t
16085+
enable_k8s_certs_via_dns = %t
1607116086
}
1607216087
}
16073-
}`, name, networkName, subnetworkName, enabled)
16088+
}`, name, networkName, subnetworkName, enabled, enabled, enabled)
1607416089
}
1607516090

1607616091
func TestAccContainerCluster_withDnsEndpointAndEnableK8sTokensViaDns(t *testing.T) {

0 commit comments

Comments
 (0)