Skip to content

Commit 56cf756

Browse files
Add DNS_SCOPE_UNSPECIFIED back and fix diffs (#13348) (#9547)
[upstream:bdc4748839e04a51a25b904ef84dfc7687bf91c1] Signed-off-by: Modular Magician <[email protected]>
1 parent 06e14df commit 56cf756

File tree

4 files changed

+62
-6
lines changed

4 files changed

+62
-6
lines changed

.changelog/13348.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
container: re-added `DNS_SCOPE_UNSPECIFIED` value to the `dns_config.cluster_dns_scope` field in `google_container_cluster` resource and suppressed diffs between `DNS_SCOPE_UNSPECIFIED` in config and empty/null in state
3+
```

google-beta/services/container/resource_container_cluster.go

+12-4
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@ func isBeenEnabled(_ context.Context, old, new, _ interface{}) bool {
188188
return false
189189
}
190190

191+
func suppressDiffForClusterDnsScope(k, o, n string, d *schema.ResourceData) bool {
192+
if o == "" && n == "DNS_SCOPE_UNSPECIFIED" {
193+
return true
194+
}
195+
return false
196+
}
197+
191198
func ResourceContainerCluster() *schema.Resource {
192199
return &schema.Resource{
193200
UseJSONNumber: true,
@@ -2179,10 +2186,11 @@ func ResourceContainerCluster() *schema.Resource {
21792186
Optional: true,
21802187
},
21812188
"cluster_dns_scope": {
2182-
Type: schema.TypeString,
2183-
ValidateFunc: validation.StringInSlice([]string{"CLUSTER_SCOPE", "VPC_SCOPE"}, false),
2184-
Description: `The scope of access to cluster DNS records.`,
2185-
Optional: true,
2189+
Type: schema.TypeString,
2190+
ValidateFunc: validation.StringInSlice([]string{"DNS_SCOPE_UNSPECIFIED", "CLUSTER_SCOPE", "VPC_SCOPE"}, false),
2191+
Description: `The scope of access to cluster DNS records.`,
2192+
Optional: true,
2193+
DiffSuppressFunc: suppressDiffForClusterDnsScope,
21862194
},
21872195
"cluster_dns_domain": {
21882196
Type: schema.TypeString,

google-beta/services/container/resource_container_cluster_test.go

+46-1
Original file line numberDiff line numberDiff line change
@@ -6042,7 +6042,21 @@ func TestAccContainerCluster_cloudDns_nil_scope(t *testing.T) {
60426042
CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
60436043
Steps: []resource.TestStep{
60446044
{
6045-
Config: testAccContainerCluster_withAdvancedDNSConfig(clusterName, false, true, true, false, ""),
6045+
Config: testAccContainerCluster_withDNSConfigWithoutScope(clusterName),
6046+
},
6047+
{
6048+
ResourceName: "google_container_cluster.primary",
6049+
ImportState: true,
6050+
ImportStateVerify: true,
6051+
ImportStateVerifyIgnore: []string{"deletion_protection"},
6052+
},
6053+
{
6054+
Config: testAccContainerCluster_withDNSConfigWithUnspecifiedScope(clusterName),
6055+
ConfigPlanChecks: resource.ConfigPlanChecks{
6056+
PreApply: []plancheck.PlanCheck{
6057+
plancheck.ExpectResourceAction("google_container_cluster.primary", plancheck.ResourceActionNoop),
6058+
},
6059+
},
60466060
},
60476061
{
60486062
ResourceName: "google_container_cluster.primary",
@@ -6054,6 +6068,37 @@ func TestAccContainerCluster_cloudDns_nil_scope(t *testing.T) {
60546068
})
60556069
}
60566070

6071+
func testAccContainerCluster_withDNSConfigWithoutScope(clusterName string) string {
6072+
return fmt.Sprintf(`
6073+
resource "google_container_cluster" "primary" {
6074+
name = "%s"
6075+
location = "us-central1-a"
6076+
initial_node_count = 2
6077+
dns_config {
6078+
cluster_dns = "CLOUD_DNS"
6079+
}
6080+
6081+
deletion_protection = false
6082+
}
6083+
`, clusterName)
6084+
}
6085+
6086+
func testAccContainerCluster_withDNSConfigWithUnspecifiedScope(clusterName string) string {
6087+
return fmt.Sprintf(`
6088+
resource "google_container_cluster" "primary" {
6089+
name = "%s"
6090+
location = "us-central1-a"
6091+
initial_node_count = 2
6092+
dns_config {
6093+
cluster_dns = "CLOUD_DNS"
6094+
cluster_dns_scope = "DNS_SCOPE_UNSPECIFIED"
6095+
}
6096+
6097+
deletion_protection = false
6098+
}
6099+
`, clusterName)
6100+
}
6101+
60576102
func TestAccContainerCluster_autopilot_withAdditiveVPCMutation(t *testing.T) {
60586103
t.Parallel()
60596104

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)