From ec67375b485385c97c549bd26c78c6cdbede0e6b Mon Sep 17 00:00:00 2001 From: The Magician Date: Thu, 30 Jun 2022 16:06:11 -0700 Subject: [PATCH] Promote gce_persistent_disk_csi_driver_config to GA (#6187) (#11999) Signed-off-by: Modular Magician --- .changelog/6187.txt | 3 ++ google/resource_container_cluster.go | 33 +++++++++++++++++++ google/resource_container_cluster_test.go | 12 +++++-- .../docs/r/container_cluster.html.markdown | 4 +-- 4 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 .changelog/6187.txt diff --git a/.changelog/6187.txt b/.changelog/6187.txt new file mode 100644 index 00000000000..e22459ac875 --- /dev/null +++ b/.changelog/6187.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +container: Promoted `gce_persistent_disk_csi_driver_config` addon in `google_container_cluster` resource to GA +``` diff --git a/google/resource_container_cluster.go b/google/resource_container_cluster.go index 0c07f6d4db5..86971d6f8d1 100644 --- a/google/resource_container_cluster.go +++ b/google/resource_container_cluster.go @@ -61,6 +61,7 @@ var ( "addons_config.0.cloudrun_config", "addons_config.0.gcp_filestore_csi_driver_config", "addons_config.0.dns_cache_config", + "addons_config.0.gce_persistent_disk_csi_driver_config", } forceNewClusterNodeConfigFields = []string{ @@ -285,6 +286,22 @@ func resourceContainerCluster() *schema.Resource { }, }, }, + "gce_persistent_disk_csi_driver_config": { + Type: schema.TypeList, + Optional: true, + Computed: true, + AtLeastOneOf: addonsConfigKeys, + MaxItems: 1, + Description: `Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver. Defaults to enabled; set disabled = true to disable.`, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "enabled": { + Type: schema.TypeBool, + Required: true, + }, + }, + }, + }, }, }, }, @@ -2723,6 +2740,14 @@ func expandClusterAddonsConfig(configured interface{}) *container.AddonsConfig { } } + if v, ok := config["gce_persistent_disk_csi_driver_config"]; ok && len(v.([]interface{})) > 0 { + addon := v.([]interface{})[0].(map[string]interface{}) + ac.GcePersistentDiskCsiDriverConfig = &container.GcePersistentDiskCsiDriverConfig{ + Enabled: addon["enabled"].(bool), + ForceSendFields: []string{"Enabled"}, + } + } + return ac } @@ -3303,6 +3328,14 @@ func flattenClusterAddonsConfig(c *container.AddonsConfig) []map[string]interfac } } + if c.GcePersistentDiskCsiDriverConfig != nil { + result["gce_persistent_disk_csi_driver_config"] = []map[string]interface{}{ + { + "enabled": c.GcePersistentDiskCsiDriverConfig.Enabled, + }, + } + } + return []map[string]interface{}{result} } diff --git a/google/resource_container_cluster_test.go b/google/resource_container_cluster_test.go index 8f3667b2325..90065532afe 100644 --- a/google/resource_container_cluster_test.go +++ b/google/resource_container_cluster_test.go @@ -2379,7 +2379,10 @@ resource "google_container_cluster" "primary" { cloudrun_config { disabled = true } - dns_cache_config { + dns_cache_config { + enabled = false + } + gce_persistent_disk_csi_driver_config { enabled = false } } @@ -2422,9 +2425,12 @@ resource "google_container_cluster" "primary" { # disabled = false disabled = true } - dns_cache_config { + dns_cache_config { enabled = true - } + } + gce_persistent_disk_csi_driver_config { + enabled = true + } } } `, projectID, clusterName) diff --git a/website/docs/r/container_cluster.html.markdown b/website/docs/r/container_cluster.html.markdown index a78c15cd886..ee264e37630 100644 --- a/website/docs/r/container_cluster.html.markdown +++ b/website/docs/r/container_cluster.html.markdown @@ -385,8 +385,8 @@ subnetwork in which the cluster's instances are launched. **Enabling/Disabling NodeLocal DNSCache in an existing cluster is a disruptive operation. All cluster nodes running GKE 1.15 and higher are recreated.** -* `gce_persistent_disk_csi_driver_config` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)). - Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver. Defaults to disabled; set `enabled = true` to enable. +* `gce_persistent_disk_csi_driver_config` - (Optional). + Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver. Defaults to disabled; set `enabled = true` to enabled. * `kalm_config` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)). Configuration for the KALM addon, which manages the lifecycle of k8s. It is disabled by default; Set `enabled = true` to enable.