Skip to content

Commit 1f15945

Browse files
zli82016Dawid212
authored andcommitted
Add DNS_SCOPE_UNSPECIFIED back and fix diffs (GoogleCloudPlatform#13348)
1 parent d2255ff commit 1f15945

File tree

3 files changed

+59
-6
lines changed

3 files changed

+59
-6
lines changed

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

+12-4
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,13 @@ func isBeenEnabled(_ context.Context, old, new, _ interface{}) bool {
192192
return false
193193
}
194194

195+
func suppressDiffForClusterDnsScope(k, o, n string, d *schema.ResourceData) bool {
196+
if o == "" && n == "DNS_SCOPE_UNSPECIFIED" {
197+
return true
198+
}
199+
return false
200+
}
201+
195202
func ResourceContainerCluster() *schema.Resource {
196203
return &schema.Resource{
197204
UseJSONNumber: true,
@@ -2205,10 +2212,11 @@ func ResourceContainerCluster() *schema.Resource {
22052212
Optional: true,
22062213
},
22072214
"cluster_dns_scope": {
2208-
Type: schema.TypeString,
2209-
ValidateFunc: validation.StringInSlice([]string{"CLUSTER_SCOPE", "VPC_SCOPE"}, false),
2210-
Description: `The scope of access to cluster DNS records.`,
2211-
Optional: true,
2215+
Type: schema.TypeString,
2216+
ValidateFunc: validation.StringInSlice([]string{"DNS_SCOPE_UNSPECIFIED", "CLUSTER_SCOPE", "VPC_SCOPE"}, false),
2217+
Description: `The scope of access to cluster DNS records.`,
2218+
Optional: true,
2219+
DiffSuppressFunc: suppressDiffForClusterDnsScope,
22122220
},
22132221
"cluster_dns_domain": {
22142222
Type: schema.TypeString,

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

+46-1
Original file line numberDiff line numberDiff line change
@@ -6065,7 +6065,21 @@ func TestAccContainerCluster_cloudDns_nil_scope(t *testing.T) {
60656065
CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
60666066
Steps: []resource.TestStep{
60676067
{
6068-
Config: testAccContainerCluster_withAdvancedDNSConfig(clusterName, false, true, true, false, ""),
6068+
Config: testAccContainerCluster_withDNSConfigWithoutScope(clusterName),
6069+
},
6070+
{
6071+
ResourceName: "google_container_cluster.primary",
6072+
ImportState: true,
6073+
ImportStateVerify: true,
6074+
ImportStateVerifyIgnore: []string{"deletion_protection"},
6075+
},
6076+
{
6077+
Config: testAccContainerCluster_withDNSConfigWithUnspecifiedScope(clusterName),
6078+
ConfigPlanChecks: resource.ConfigPlanChecks{
6079+
PreApply: []plancheck.PlanCheck{
6080+
plancheck.ExpectResourceAction("google_container_cluster.primary", plancheck.ResourceActionNoop),
6081+
},
6082+
},
60696083
},
60706084
{
60716085
ResourceName: "google_container_cluster.primary",
@@ -6077,6 +6091,37 @@ func TestAccContainerCluster_cloudDns_nil_scope(t *testing.T) {
60776091
})
60786092
}
60796093

6094+
func testAccContainerCluster_withDNSConfigWithoutScope(clusterName string) string {
6095+
return fmt.Sprintf(`
6096+
resource "google_container_cluster" "primary" {
6097+
name = "%s"
6098+
location = "us-central1-a"
6099+
initial_node_count = 2
6100+
dns_config {
6101+
cluster_dns = "CLOUD_DNS"
6102+
}
6103+
6104+
deletion_protection = false
6105+
}
6106+
`, clusterName)
6107+
}
6108+
6109+
func testAccContainerCluster_withDNSConfigWithUnspecifiedScope(clusterName string) string {
6110+
return fmt.Sprintf(`
6111+
resource "google_container_cluster" "primary" {
6112+
name = "%s"
6113+
location = "us-central1-a"
6114+
initial_node_count = 2
6115+
dns_config {
6116+
cluster_dns = "CLOUD_DNS"
6117+
cluster_dns_scope = "DNS_SCOPE_UNSPECIFIED"
6118+
}
6119+
6120+
deletion_protection = false
6121+
}
6122+
`, clusterName)
6123+
}
6124+
60806125
func TestAccContainerCluster_autopilot_withAdditiveVPCMutation(t *testing.T) {
60816126
t.Parallel()
60826127

mmv1/third_party/terraform/website/docs/r/container_cluster.html.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@ linux_node_config {
14271427

14281428
* `cluster_dns` - (Optional) Which in-cluster DNS provider should be used. `PROVIDER_UNSPECIFIED` (default) or `PLATFORM_DEFAULT` or `CLOUD_DNS`.
14291429

1430-
* `cluster_dns_scope` - (Optional) The scope of access to cluster DNS records. `DNS_SCOPE_UNSPECIFIED` (default) or `CLUSTER_SCOPE` or `VPC_SCOPE`.
1430+
* `cluster_dns_scope` - (Optional) The scope of access to cluster DNS records. `DNS_SCOPE_UNSPECIFIED` or `CLUSTER_SCOPE` or `VPC_SCOPE`. If the `cluster_dns` field is set to `CLOUD_DNS`, `DNS_SCOPE_UNSPECIFIED` and empty/null behave like `CLUSTER_SCOPE`.
14311431

14321432
* `cluster_dns_domain` - (Optional) The suffix used for all cluster service records.
14331433

0 commit comments

Comments
 (0)