Skip to content

Commit d2e4999

Browse files
Add DNS_SCOPE_UNSPECIFIED back and fix diffs (#13348) (#21861)
[upstream:bdc4748839e04a51a25b904ef84dfc7687bf91c1] Signed-off-by: Modular Magician <[email protected]>
1 parent bd2acc0 commit d2e4999

File tree

4 files changed

+62
-6
lines changed

4 files changed

+62
-6
lines changed

.changelog/13348.txt

Lines changed: 3 additions & 0 deletions
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/services/container/resource_container_cluster.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,13 @@ func isBeenEnabled(_ context.Context, old, new, _ interface{}) bool {
186186
return false
187187
}
188188

189+
func suppressDiffForClusterDnsScope(k, o, n string, d *schema.ResourceData) bool {
190+
if o == "" && n == "DNS_SCOPE_UNSPECIFIED" {
191+
return true
192+
}
193+
return false
194+
}
195+
189196
func ResourceContainerCluster() *schema.Resource {
190197
return &schema.Resource{
191198
UseJSONNumber: true,
@@ -2008,10 +2015,11 @@ func ResourceContainerCluster() *schema.Resource {
20082015
Optional: true,
20092016
},
20102017
"cluster_dns_scope": {
2011-
Type: schema.TypeString,
2012-
ValidateFunc: validation.StringInSlice([]string{"CLUSTER_SCOPE", "VPC_SCOPE"}, false),
2013-
Description: `The scope of access to cluster DNS records.`,
2014-
Optional: true,
2018+
Type: schema.TypeString,
2019+
ValidateFunc: validation.StringInSlice([]string{"DNS_SCOPE_UNSPECIFIED", "CLUSTER_SCOPE", "VPC_SCOPE"}, false),
2020+
Description: `The scope of access to cluster DNS records.`,
2021+
Optional: true,
2022+
DiffSuppressFunc: suppressDiffForClusterDnsScope,
20152023
},
20162024
"cluster_dns_domain": {
20172025
Type: schema.TypeString,

google/services/container/resource_container_cluster_test.go

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5609,7 +5609,21 @@ func TestAccContainerCluster_cloudDns_nil_scope(t *testing.T) {
56095609
CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
56105610
Steps: []resource.TestStep{
56115611
{
5612-
Config: testAccContainerCluster_withAdvancedDNSConfig(clusterName, false, true, true, false, ""),
5612+
Config: testAccContainerCluster_withDNSConfigWithoutScope(clusterName),
5613+
},
5614+
{
5615+
ResourceName: "google_container_cluster.primary",
5616+
ImportState: true,
5617+
ImportStateVerify: true,
5618+
ImportStateVerifyIgnore: []string{"deletion_protection"},
5619+
},
5620+
{
5621+
Config: testAccContainerCluster_withDNSConfigWithUnspecifiedScope(clusterName),
5622+
ConfigPlanChecks: resource.ConfigPlanChecks{
5623+
PreApply: []plancheck.PlanCheck{
5624+
plancheck.ExpectResourceAction("google_container_cluster.primary", plancheck.ResourceActionNoop),
5625+
},
5626+
},
56135627
},
56145628
{
56155629
ResourceName: "google_container_cluster.primary",
@@ -5621,6 +5635,37 @@ func TestAccContainerCluster_cloudDns_nil_scope(t *testing.T) {
56215635
})
56225636
}
56235637

5638+
func testAccContainerCluster_withDNSConfigWithoutScope(clusterName string) string {
5639+
return fmt.Sprintf(`
5640+
resource "google_container_cluster" "primary" {
5641+
name = "%s"
5642+
location = "us-central1-a"
5643+
initial_node_count = 2
5644+
dns_config {
5645+
cluster_dns = "CLOUD_DNS"
5646+
}
5647+
5648+
deletion_protection = false
5649+
}
5650+
`, clusterName)
5651+
}
5652+
5653+
func testAccContainerCluster_withDNSConfigWithUnspecifiedScope(clusterName string) string {
5654+
return fmt.Sprintf(`
5655+
resource "google_container_cluster" "primary" {
5656+
name = "%s"
5657+
location = "us-central1-a"
5658+
initial_node_count = 2
5659+
dns_config {
5660+
cluster_dns = "CLOUD_DNS"
5661+
cluster_dns_scope = "DNS_SCOPE_UNSPECIFIED"
5662+
}
5663+
5664+
deletion_protection = false
5665+
}
5666+
`, clusterName)
5667+
}
5668+
56245669
func TestAccContainerCluster_autopilot_withAdditiveVPCMutation(t *testing.T) {
56255670
t.Parallel()
56265671

website/docs/r/container_cluster.html.markdown

Lines changed: 1 addition & 1 deletion
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)