Skip to content

Commit

Permalink
feat: Remove force replacement from gcfs_config
Browse files Browse the repository at this point in the history
  • Loading branch information
dominykasn committed Aug 28, 2024
1 parent 12fcf34 commit ca83c4b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,11 @@ func schemaGcfsConfig(forceNew bool) *schema.Schema {
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`,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,23 @@ 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",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccContainerNodePool_gcfsConfig(cluster, np, networkName, subnetworkName, false),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("google_container_node_pool.np",
"node_config.0.gcfs_config.0.enabled", "false"),
),
},
{
ResourceName: "google_container_node_pool.np",
Expand All @@ -1715,7 +1731,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"
Expand All @@ -1736,7 +1752,7 @@ resource "google_container_node_pool" "np" {
machine_type = "n1-standard-8"
image_type = "COS_CONTAINERD"
gcfs_config {
enabled = true
enabled = %t
}
}
}
Expand Down Expand Up @@ -4719,30 +4735,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_version" "secret-version-basic" {
secret = google_secret_manager_secret.secret-basic.id
secret_data = "dummypassword"
}

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}[email protected]"
depends_on = [google_secret_manager_secret_version.secret-version-basic]
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}[email protected]"
depends_on = [google_secret_manager_secret_version.secret-version-basic]
}

resource "google_container_cluster" "cluster" {
Expand All @@ -4753,13 +4769,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",
Expand Down Expand Up @@ -4852,4 +4868,4 @@ resource "google_container_node_pool" "np" {
}
}
`, cluster, np)
}
}

0 comments on commit ca83c4b

Please sign in to comment.