From 7cea789813584f73d97cdc9cbd4dca1661d4aebf Mon Sep 17 00:00:00 2001 From: venkykuberan Date: Wed, 29 Apr 2020 18:44:14 -0700 Subject: [PATCH 1/4] kalm addon config added --- .../resource_container_cluster.go.erb | 32 +++++++++++++++++++ .../docs/r/container_cluster.html.markdown | 3 ++ 2 files changed, 35 insertions(+) diff --git a/third_party/terraform/resources/resource_container_cluster.go.erb b/third_party/terraform/resources/resource_container_cluster.go.erb index 8595726af4e5..0185754fdcfa 100644 --- a/third_party/terraform/resources/resource_container_cluster.go.erb +++ b/third_party/terraform/resources/resource_container_cluster.go.erb @@ -58,6 +58,7 @@ var ( "addons_config.0.cloudrun_config", "addons_config.0.dns_cache_config", "addons_config.0.gce_persistent_disk_csi_driver_config", + "addons_config.0.kalm_config", <% end -%> } ) @@ -305,6 +306,21 @@ func resourceContainerCluster() *schema.Resource { }, }, }, + "kalm_config": { + Type: schema.TypeList, + Optional: true, + Computed: true, + AtLeastOneOf: addonsConfigKeys, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "enabled": { + Type: schema.TypeBool, + Required: true, + }, + }, + }, + }, <% end -%> }, }, @@ -2250,6 +2266,14 @@ func expandClusterAddonsConfig(configured interface{}) *containerBeta.AddonsConf ForceSendFields: []string{"Enabled"}, } } + + if v, ok := config["kalm_config"]; ok && len(v.([]interface{})) > 0 { + addon := v.([]interface{})[0].(map[string]interface{}) + ac.KalmConfig = &containerBeta.KalmConfig{ + Enabled: addon["enabled"].(bool), + ForceSendFields: []string{"Enabled"}, + } + } <% end -%> return ac @@ -2675,6 +2699,14 @@ func flattenClusterAddonsConfig(c *containerBeta.AddonsConfig) []map[string]inte }, } } + + if c.KalmConfig != nil { + result["kalm_config"] = []map[string]interface{}{ + { + "enabled": c.KalmConfig.Enabled, + }, + } + } <% end -%> return []map[string]interface{}{result} } diff --git a/third_party/terraform/website/docs/r/container_cluster.html.markdown b/third_party/terraform/website/docs/r/container_cluster.html.markdown index da215e182ffc..13d7db6360a5 100644 --- a/third_party/terraform/website/docs/r/container_cluster.html.markdown +++ b/third_party/terraform/website/docs/r/container_cluster.html.markdown @@ -338,6 +338,9 @@ The `addons_config` block supports: * `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. +* `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. + This example `addons_config` disables two addons: ```hcl From 2e9a868a52dab9307b18dc26e19caa4c4d2e907c Mon Sep 17 00:00:00 2001 From: venkykuberan Date: Fri, 1 May 2020 12:50:05 -0700 Subject: [PATCH 2/4] kalm addon tests added --- .../tests/resource_container_cluster_test.go.erb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/third_party/terraform/tests/resource_container_cluster_test.go.erb b/third_party/terraform/tests/resource_container_cluster_test.go.erb index 232358316c01..2328388c984a 100644 --- a/third_party/terraform/tests/resource_container_cluster_test.go.erb +++ b/third_party/terraform/tests/resource_container_cluster_test.go.erb @@ -1991,7 +1991,10 @@ resource "google_container_cluster" "primary" { } gce_persistent_disk_csi_driver_config { enabled = false - } + } + kalm_config { + enabled = false + } <% end -%> } } @@ -2030,7 +2033,10 @@ resource "google_container_cluster" "primary" { } gce_persistent_disk_csi_driver_config { enabled = true - } + } + kalm_config { + enabled = true + } <% end -%> } } From 28c2b0d9cb31593ee031f94e59c340d4f67f8aa9 Mon Sep 17 00:00:00 2001 From: venkykuberan Date: Sat, 2 May 2020 14:15:06 -0700 Subject: [PATCH 3/4] Update resource_container_cluster_test.go.erb --- .../tests/resource_container_cluster_test.go.erb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/third_party/terraform/tests/resource_container_cluster_test.go.erb b/third_party/terraform/tests/resource_container_cluster_test.go.erb index 2328388c984a..082fcd14054f 100644 --- a/third_party/terraform/tests/resource_container_cluster_test.go.erb +++ b/third_party/terraform/tests/resource_container_cluster_test.go.erb @@ -1991,10 +1991,10 @@ resource "google_container_cluster" "primary" { } gce_persistent_disk_csi_driver_config { enabled = false - } - kalm_config { - enabled = false - } + } + kalm_config { + enabled = false + } <% end -%> } } From fd5144284d7e2a6d8a4fe538f221fdff31e44ef0 Mon Sep 17 00:00:00 2001 From: venkykuberan Date: Sat, 2 May 2020 14:28:46 -0700 Subject: [PATCH 4/4] PR comments fixed --- .../tests/resource_container_cluster_test.go.erb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/third_party/terraform/tests/resource_container_cluster_test.go.erb b/third_party/terraform/tests/resource_container_cluster_test.go.erb index 082fcd14054f..eeab48f70bbb 100644 --- a/third_party/terraform/tests/resource_container_cluster_test.go.erb +++ b/third_party/terraform/tests/resource_container_cluster_test.go.erb @@ -1991,9 +1991,9 @@ resource "google_container_cluster" "primary" { } gce_persistent_disk_csi_driver_config { enabled = false - } - kalm_config { - enabled = false + } + kalm_config { + enabled = false } <% end -%> } @@ -2035,7 +2035,7 @@ resource "google_container_cluster" "primary" { enabled = true } kalm_config { - enabled = true + enabled = true } <% end -%> }