diff --git a/mmv1/third_party/terraform/services/container/go/node_config.go.tmpl b/mmv1/third_party/terraform/services/container/go/node_config.go.tmpl index c5e1425a1f0a..eded879ff7ee 100644 --- a/mmv1/third_party/terraform/services/container/go/node_config.go.tmpl +++ b/mmv1/third_party/terraform/services/container/go/node_config.go.tmpl @@ -99,13 +99,12 @@ func schemaLoggingVariant() *schema.Schema { } } -func schemaGcfsConfig(forceNew bool) *schema.Schema { +func schemaGcfsConfig() *schema.Schema { return &schema.Schema{ Type: schema.TypeList, Optional: true, MaxItems: 1, Description: `GCFS configuration for this node.`, - ForceNew: forceNew, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "enabled": { @@ -339,7 +338,7 @@ func schemaNodeConfig() *schema.Schema { }, }, - "gcfs_config": schemaGcfsConfig(true), + "gcfs_config": schemaGcfsConfig(), "gvnic": { Type: schema.TypeList, diff --git a/mmv1/third_party/terraform/services/container/go/resource_container_cluster.go.tmpl b/mmv1/third_party/terraform/services/container/go/resource_container_cluster.go.tmpl index 9707d9febc5b..7d43a21c88c1 100644 --- a/mmv1/third_party/terraform/services/container/go/resource_container_cluster.go.tmpl +++ b/mmv1/third_party/terraform/services/container/go/resource_container_cluster.go.tmpl @@ -159,7 +159,7 @@ func clusterSchemaNodePoolDefaults() *schema.Schema { Schema: map[string]*schema.Schema{ "containerd_config": schemaContainerdConfig(), {{- if ne $.TargetVersionName "ga" }} - "gcfs_config": schemaGcfsConfig(false), + "gcfs_config": schemaGcfsConfig(), {{- end }} "insecure_kubelet_readonly_port_enabled": schemaInsecureKubeletReadonlyPortEnabled(), "logging_variant": schemaLoggingVariant(), diff --git a/mmv1/third_party/terraform/services/container/go/resource_container_node_pool_test.go.tmpl b/mmv1/third_party/terraform/services/container/go/resource_container_node_pool_test.go.tmpl index 36a609075836..748e0cb13375 100644 --- a/mmv1/third_party/terraform/services/container/go/resource_container_node_pool_test.go.tmpl +++ b/mmv1/third_party/terraform/services/container/go/resource_container_node_pool_test.go.tmpl @@ -1718,7 +1718,11 @@ func TestAccContainerNodePool_gcfsConfig(t *testing.T) { CheckDestroy: testAccCheckContainerNodePoolDestroyProducer(t), Steps: []resource.TestStep{ { - Config: testAccContainerNodePool_gcfsConfig(cluster, np, networkName, subnetworkName), + Config: testAccContainerNodePool_gcfsConfig(cluster, np, networkName, subnetworkName, true), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("google_container_node_pool.np", + "node_config.0.gcfs_config.0.enabled", "true"), + ), }, { ResourceName: "google_container_node_pool.np", @@ -1729,7 +1733,7 @@ func TestAccContainerNodePool_gcfsConfig(t *testing.T) { }) } -func testAccContainerNodePool_gcfsConfig(cluster, np, networkName, subnetworkName string) string { +func testAccContainerNodePool_gcfsConfig(cluster, np, networkName, subnetworkName string, enabled bool) string { return fmt.Sprintf(` resource "google_container_cluster" "cluster" { name = "%s" @@ -1750,11 +1754,11 @@ resource "google_container_node_pool" "np" { machine_type = "n1-standard-8" image_type = "COS_CONTAINERD" gcfs_config { - enabled = true + enabled = %t } } } -`, cluster, networkName, subnetworkName, np) +`, cluster, networkName, subnetworkName, np, enabled) } func TestAccContainerNodePool_gvnic(t *testing.T) { @@ -4734,30 +4738,30 @@ func TestAccContainerNodePool_privateRegistry(t *testing.T) { func testAccContainerNodePool_privateRegistryEnabled(secretID, cluster, nodepool, network, subnetwork string) string { return fmt.Sprintf(` -data "google_project" "test_project" { +data "google_project" "test_project" { + } + +resource "google_secret_manager_secret" "secret-basic" { + secret_id = "%s" + replication { + user_managed { + replicas { + location = "us-central1" + } + } } +} -resource "google_secret_manager_secret" "secret-basic" { - secret_id = "%s" - replication { - user_managed { - replicas { - location = "us-central1" - } - } - } -} - -resource "google_secret_manager_secret_version" "secret-version-basic" { - secret = google_secret_manager_secret.secret-basic.id - secret_data = "dummypassword" - } - -resource "google_secret_manager_secret_iam_member" "secret_iam" { - secret_id = google_secret_manager_secret.secret-basic.id - role = "roles/secretmanager.admin" - member = "serviceAccount:${data.google_project.test_project.number}-compute@developer.gserviceaccount.com" - depends_on = [google_secret_manager_secret_version.secret-version-basic] +resource "google_secret_manager_secret_version" "secret-version-basic" { + secret = google_secret_manager_secret.secret-basic.id + secret_data = "dummypassword" + } + +resource "google_secret_manager_secret_iam_member" "secret_iam" { + secret_id = google_secret_manager_secret.secret-basic.id + role = "roles/secretmanager.admin" + member = "serviceAccount:${data.google_project.test_project.number}-compute@developer.gserviceaccount.com" + depends_on = [google_secret_manager_secret_version.secret-version-basic] } resource "google_container_cluster" "cluster" { @@ -4768,13 +4772,13 @@ resource "google_container_cluster" "cluster" { network = "%s" subnetwork = "%s" } - + resource "google_container_node_pool" "np" { name = "%s" location = "us-central1-a" cluster = google_container_cluster.cluster.name initial_node_count = 1 - + node_config { oauth_scopes = [ "https://www.googleapis.com/auth/cloud-platform", diff --git a/mmv1/third_party/terraform/services/container/node_config.go.erb b/mmv1/third_party/terraform/services/container/node_config.go.erb index fd9feb10e467..3165f7c8bb79 100644 --- a/mmv1/third_party/terraform/services/container/node_config.go.erb +++ b/mmv1/third_party/terraform/services/container/node_config.go.erb @@ -100,19 +100,17 @@ func schemaLoggingVariant() *schema.Schema { } } -func schemaGcfsConfig(forceNew bool) *schema.Schema { +func schemaGcfsConfig() *schema.Schema { return &schema.Schema{ Type: schema.TypeList, Optional: true, MaxItems: 1, Description: `GCFS configuration for this node.`, - ForceNew: forceNew, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "enabled": { Type: schema.TypeBool, Required: true, - ForceNew: forceNew, Description: `Whether or not GCFS is enabled`, }, }, @@ -340,7 +338,7 @@ func schemaNodeConfig() *schema.Schema { }, }, - "gcfs_config": schemaGcfsConfig(true), + "gcfs_config": schemaGcfsConfig(), "gvnic": { Type: schema.TypeList, diff --git a/mmv1/third_party/terraform/services/container/resource_container_cluster.go.erb b/mmv1/third_party/terraform/services/container/resource_container_cluster.go.erb index 1957be85b5b2..0feb0b42e5ed 100644 --- a/mmv1/third_party/terraform/services/container/resource_container_cluster.go.erb +++ b/mmv1/third_party/terraform/services/container/resource_container_cluster.go.erb @@ -160,7 +160,7 @@ func clusterSchemaNodePoolDefaults() *schema.Schema { Schema: map[string]*schema.Schema{ "containerd_config": schemaContainerdConfig(), <% unless version == 'ga' -%> - "gcfs_config": schemaGcfsConfig(false), + "gcfs_config": schemaGcfsConfig(), <% end -%> "insecure_kubelet_readonly_port_enabled": schemaInsecureKubeletReadonlyPortEnabled(), "logging_variant": schemaLoggingVariant(), diff --git a/mmv1/third_party/terraform/services/container/resource_container_node_pool_test.go.erb b/mmv1/third_party/terraform/services/container/resource_container_node_pool_test.go.erb index 9b00517cf10e..794e0c90f1e7 100644 --- a/mmv1/third_party/terraform/services/container/resource_container_node_pool_test.go.erb +++ b/mmv1/third_party/terraform/services/container/resource_container_node_pool_test.go.erb @@ -1719,7 +1719,11 @@ func TestAccContainerNodePool_gcfsConfig(t *testing.T) { CheckDestroy: testAccCheckContainerNodePoolDestroyProducer(t), Steps: []resource.TestStep{ { - Config: testAccContainerNodePool_gcfsConfig(cluster, np, networkName, subnetworkName), + Config: testAccContainerNodePool_gcfsConfig(cluster, np, networkName, subnetworkName, true), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("google_container_node_pool.np", + "node_config.0.gcfs_config.0.enabled", "true"), + ), }, { ResourceName: "google_container_node_pool.np", @@ -1730,7 +1734,7 @@ func TestAccContainerNodePool_gcfsConfig(t *testing.T) { }) } -func testAccContainerNodePool_gcfsConfig(cluster, np, networkName, subnetworkName string) string { +func testAccContainerNodePool_gcfsConfig(cluster, np, networkName, subnetworkName string, enabled bool) string { return fmt.Sprintf(` resource "google_container_cluster" "cluster" { name = "%s" @@ -1751,11 +1755,11 @@ resource "google_container_node_pool" "np" { machine_type = "n1-standard-8" image_type = "COS_CONTAINERD" gcfs_config { - enabled = true + enabled = %t } } } -`, cluster, networkName, subnetworkName, np) +`, cluster, networkName, subnetworkName, np, enabled) } func TestAccContainerNodePool_gvnic(t *testing.T) { @@ -4735,30 +4739,30 @@ func TestAccContainerNodePool_privateRegistry(t *testing.T) { func testAccContainerNodePool_privateRegistryEnabled(secretID, cluster, nodepool, network, subnetwork string) string { return fmt.Sprintf(` -data "google_project" "test_project" { +data "google_project" "test_project" { + } + +resource "google_secret_manager_secret" "secret-basic" { + secret_id = "%s" + replication { + user_managed { + replicas { + location = "us-central1" + } + } } +} -resource "google_secret_manager_secret" "secret-basic" { - secret_id = "%s" - replication { - user_managed { - replicas { - location = "us-central1" - } - } - } -} - -resource "google_secret_manager_secret_version" "secret-version-basic" { - secret = google_secret_manager_secret.secret-basic.id - secret_data = "dummypassword" - } - -resource "google_secret_manager_secret_iam_member" "secret_iam" { - secret_id = google_secret_manager_secret.secret-basic.id - role = "roles/secretmanager.admin" - member = "serviceAccount:${data.google_project.test_project.number}-compute@developer.gserviceaccount.com" - depends_on = [google_secret_manager_secret_version.secret-version-basic] +resource "google_secret_manager_secret_version" "secret-version-basic" { + secret = google_secret_manager_secret.secret-basic.id + secret_data = "dummypassword" + } + +resource "google_secret_manager_secret_iam_member" "secret_iam" { + secret_id = google_secret_manager_secret.secret-basic.id + role = "roles/secretmanager.admin" + member = "serviceAccount:${data.google_project.test_project.number}-compute@developer.gserviceaccount.com" + depends_on = [google_secret_manager_secret_version.secret-version-basic] } resource "google_container_cluster" "cluster" { @@ -4769,13 +4773,13 @@ resource "google_container_cluster" "cluster" { network = "%s" subnetwork = "%s" } - + resource "google_container_node_pool" "np" { name = "%s" location = "us-central1-a" cluster = google_container_cluster.cluster.name initial_node_count = 1 - + node_config { oauth_scopes = [ "https://www.googleapis.com/auth/cloud-platform",