Skip to content

Commit 89f495f

Browse files
Add case sensitivity diff suppression for enums. (#8626) (#15491)
Signed-off-by: Modular Magician <[email protected]>
1 parent c57fd3e commit 89f495f

7 files changed

+1116
-17
lines changed

.changelog/8626.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
containeraws: added diff suppression for case changes of enum values in `google_container_aws_cluster` and `google_container_aws_node_pool`
3+
```

google/services/containeraws/resource_container_aws_cluster.go

+11-9
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,12 @@ func ContainerAwsClusterControlPlaneMainVolumeSchema() *schema.Resource {
391391
},
392392

393393
"volume_type": {
394-
Type: schema.TypeString,
395-
Computed: true,
396-
Optional: true,
397-
ForceNew: true,
398-
Description: "Optional. Type of the EBS volume. When unspecified, it defaults to GP2 volume. Possible values: VOLUME_TYPE_UNSPECIFIED, GP2, GP3",
394+
Type: schema.TypeString,
395+
Computed: true,
396+
Optional: true,
397+
ForceNew: true,
398+
DiffSuppressFunc: tpgresource.CompareCaseInsensitive,
399+
Description: "Optional. Type of the EBS volume. When unspecified, it defaults to GP2 volume. Possible values: VOLUME_TYPE_UNSPECIFIED, GP2, GP3",
399400
},
400401
},
401402
}
@@ -450,10 +451,11 @@ func ContainerAwsClusterControlPlaneRootVolumeSchema() *schema.Resource {
450451
},
451452

452453
"volume_type": {
453-
Type: schema.TypeString,
454-
Computed: true,
455-
Optional: true,
456-
Description: "Optional. Type of the EBS volume. When unspecified, it defaults to GP2 volume. Possible values: VOLUME_TYPE_UNSPECIFIED, GP2, GP3",
454+
Type: schema.TypeString,
455+
Computed: true,
456+
Optional: true,
457+
DiffSuppressFunc: tpgresource.CompareCaseInsensitive,
458+
Description: "Optional. Type of the EBS volume. When unspecified, it defaults to GP2 volume. Possible values: VOLUME_TYPE_UNSPECIFIED, GP2, GP3",
457459
},
458460
},
459461
}

google/services/containeraws/resource_container_aws_cluster_generated_test.go

+224
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,50 @@ func TestAccContainerAwsCluster_BasicHandWritten(t *testing.T) {
7777
},
7878
})
7979
}
80+
func TestAccContainerAwsCluster_BasicEnumHandWritten(t *testing.T) {
81+
t.Parallel()
82+
83+
context := map[string]interface{}{
84+
"aws_acct_id": "111111111111",
85+
"aws_db_key": "00000000-0000-0000-0000-17aad2f0f61f",
86+
"aws_region": "us-west-2",
87+
"aws_sg": "sg-0b3f63cb91b247628",
88+
"aws_subnet": "subnet-0b3f63cb91b247628",
89+
"aws_vol_key": "00000000-0000-0000-0000-17aad2f0f61f",
90+
"aws_vpc": "vpc-0b3f63cb91b247628",
91+
"byo_prefix": "mmv2",
92+
"project_name": envvar.GetTestProjectFromEnv(),
93+
"project_number": envvar.GetTestProjectNumberFromEnv(),
94+
"service_acct": envvar.GetTestServiceAccountFromEnv(t),
95+
"random_suffix": acctest.RandString(t, 10),
96+
}
97+
98+
acctest.VcrTest(t, resource.TestCase{
99+
PreCheck: func() { acctest.AccTestPreCheck(t) },
100+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
101+
CheckDestroy: testAccCheckContainerAwsClusterDestroyProducer(t),
102+
Steps: []resource.TestStep{
103+
{
104+
Config: testAccContainerAwsCluster_BasicEnumHandWritten(context),
105+
},
106+
{
107+
ResourceName: "google_container_aws_cluster.primary",
108+
ImportState: true,
109+
ImportStateVerify: true,
110+
ImportStateVerifyIgnore: []string{"fleet.0.project"},
111+
},
112+
{
113+
Config: testAccContainerAwsCluster_BasicEnumHandWrittenUpdate0(context),
114+
},
115+
{
116+
ResourceName: "google_container_aws_cluster.primary",
117+
ImportState: true,
118+
ImportStateVerify: true,
119+
ImportStateVerifyIgnore: []string{"fleet.0.project"},
120+
},
121+
},
122+
})
123+
}
80124

81125
func testAccContainerAwsCluster_BasicHandWritten(context map[string]interface{}) string {
82126
return acctest.Nprintf(`
@@ -255,6 +299,186 @@ resource "google_container_aws_cluster" "primary" {
255299
}
256300
257301
302+
`, context)
303+
}
304+
305+
func testAccContainerAwsCluster_BasicEnumHandWritten(context map[string]interface{}) string {
306+
return acctest.Nprintf(`
307+
data "google_container_aws_versions" "versions" {
308+
project = "%{project_name}"
309+
location = "us-west1"
310+
}
311+
312+
resource "google_container_aws_cluster" "primary" {
313+
authorization {
314+
admin_users {
315+
username = "%{service_acct}"
316+
}
317+
}
318+
319+
aws_region = "%{aws_region}"
320+
321+
control_plane {
322+
aws_services_authentication {
323+
role_arn = "arn:aws:iam::%{aws_acct_id}:role/%{byo_prefix}-1p-dev-oneplatform"
324+
role_session_name = "%{byo_prefix}-1p-dev-session"
325+
}
326+
327+
config_encryption {
328+
kms_key_arn = "arn:aws:kms:%{aws_region}:%{aws_acct_id}:key/%{aws_db_key}"
329+
}
330+
331+
database_encryption {
332+
kms_key_arn = "arn:aws:kms:%{aws_region}:%{aws_acct_id}:key/%{aws_db_key}"
333+
}
334+
335+
iam_instance_profile = "%{byo_prefix}-1p-dev-controlplane"
336+
subnet_ids = ["%{aws_subnet}"]
337+
version = "${data.google_container_aws_versions.versions.valid_versions[0]}"
338+
instance_type = "t3.medium"
339+
340+
main_volume {
341+
iops = 3000
342+
kms_key_arn = "arn:aws:kms:%{aws_region}:%{aws_acct_id}:key/%{aws_vol_key}"
343+
size_gib = 10
344+
volume_type = "gp3"
345+
}
346+
347+
proxy_config {
348+
secret_arn = "arn:aws:secretsmanager:us-west-2:126285863215:secret:proxy_config20210824150329476300000001-ABCDEF"
349+
secret_version = "12345678-ABCD-EFGH-IJKL-987654321098"
350+
}
351+
352+
root_volume {
353+
iops = 3000
354+
kms_key_arn = "arn:aws:kms:%{aws_region}:%{aws_acct_id}:key/%{aws_vol_key}"
355+
size_gib = 10
356+
volume_type = "gp3"
357+
}
358+
359+
security_group_ids = ["%{aws_sg}"]
360+
361+
ssh_config {
362+
ec2_key_pair = "%{byo_prefix}-1p-dev-ssh"
363+
}
364+
365+
tags = {
366+
owner = "%{service_acct}"
367+
}
368+
}
369+
370+
fleet {
371+
project = "%{project_number}"
372+
}
373+
374+
location = "us-west1"
375+
name = "tf-test-name%{random_suffix}"
376+
377+
networking {
378+
pod_address_cidr_blocks = ["10.2.0.0/16"]
379+
service_address_cidr_blocks = ["10.1.0.0/16"]
380+
vpc_id = "%{aws_vpc}"
381+
}
382+
383+
annotations = {
384+
label-one = "value-one"
385+
}
386+
387+
description = "A sample aws cluster"
388+
project = "%{project_name}"
389+
}
390+
391+
392+
`, context)
393+
}
394+
395+
func testAccContainerAwsCluster_BasicEnumHandWrittenUpdate0(context map[string]interface{}) string {
396+
return acctest.Nprintf(`
397+
data "google_container_aws_versions" "versions" {
398+
project = "%{project_name}"
399+
location = "us-west1"
400+
}
401+
402+
resource "google_container_aws_cluster" "primary" {
403+
authorization {
404+
admin_users {
405+
username = "%{service_acct}"
406+
}
407+
}
408+
409+
aws_region = "%{aws_region}"
410+
411+
control_plane {
412+
aws_services_authentication {
413+
role_arn = "arn:aws:iam::%{aws_acct_id}:role/%{byo_prefix}-1p-dev-oneplatform"
414+
role_session_name = "%{byo_prefix}-1p-dev-session"
415+
}
416+
417+
config_encryption {
418+
kms_key_arn = "arn:aws:kms:%{aws_region}:%{aws_acct_id}:key/%{aws_db_key}"
419+
}
420+
421+
database_encryption {
422+
kms_key_arn = "arn:aws:kms:%{aws_region}:%{aws_acct_id}:key/%{aws_db_key}"
423+
}
424+
425+
iam_instance_profile = "%{byo_prefix}-1p-dev-controlplane"
426+
subnet_ids = ["%{aws_subnet}"]
427+
version = "${data.google_container_aws_versions.versions.valid_versions[0]}"
428+
instance_type = "t3.medium"
429+
430+
main_volume {
431+
iops = 3000
432+
kms_key_arn = "arn:aws:kms:%{aws_region}:%{aws_acct_id}:key/%{aws_vol_key}"
433+
size_gib = 10
434+
volume_type = "gp3"
435+
}
436+
437+
proxy_config {
438+
secret_arn = "arn:aws:secretsmanager:us-west-2:126285863215:secret:proxy_config20210824150329476300000001-ABCDEF"
439+
secret_version = "12345678-ABCD-EFGH-IJKL-987654321098"
440+
}
441+
442+
root_volume {
443+
iops = 3000
444+
kms_key_arn = "arn:aws:kms:%{aws_region}:%{aws_acct_id}:key/%{aws_vol_key}"
445+
size_gib = 10
446+
volume_type = "gp3"
447+
}
448+
449+
security_group_ids = ["%{aws_sg}"]
450+
451+
ssh_config {
452+
ec2_key_pair = "%{byo_prefix}-1p-dev-ssh"
453+
}
454+
455+
tags = {
456+
owner = "%{service_acct}"
457+
}
458+
}
459+
460+
fleet {
461+
project = "%{project_number}"
462+
}
463+
464+
location = "us-west1"
465+
name = "tf-test-name%{random_suffix}"
466+
467+
networking {
468+
pod_address_cidr_blocks = ["10.2.0.0/16"]
469+
service_address_cidr_blocks = ["10.1.0.0/16"]
470+
vpc_id = "%{aws_vpc}"
471+
}
472+
473+
annotations = {
474+
label-two = "value-two"
475+
}
476+
477+
description = "An updated sample aws cluster"
478+
project = "%{project_name}"
479+
}
480+
481+
258482
`, context)
259483
}
260484

google/services/containeraws/resource_container_aws_node_pool.go

+10-8
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,11 @@ func ContainerAwsNodePoolConfigRootVolumeSchema() *schema.Resource {
356356
},
357357

358358
"volume_type": {
359-
Type: schema.TypeString,
360-
Computed: true,
361-
Optional: true,
362-
Description: "Optional. Type of the EBS volume. When unspecified, it defaults to GP2 volume. Possible values: VOLUME_TYPE_UNSPECIFIED, GP2, GP3",
359+
Type: schema.TypeString,
360+
Computed: true,
361+
Optional: true,
362+
DiffSuppressFunc: tpgresource.CompareCaseInsensitive,
363+
Description: "Optional. Type of the EBS volume. When unspecified, it defaults to GP2 volume. Possible values: VOLUME_TYPE_UNSPECIFIED, GP2, GP3",
363364
},
364365
},
365366
}
@@ -381,10 +382,11 @@ func ContainerAwsNodePoolConfigTaintsSchema() *schema.Resource {
381382
return &schema.Resource{
382383
Schema: map[string]*schema.Schema{
383384
"effect": {
384-
Type: schema.TypeString,
385-
Required: true,
386-
ForceNew: true,
387-
Description: "The taint effect. Possible values: EFFECT_UNSPECIFIED, NO_SCHEDULE, PREFER_NO_SCHEDULE, NO_EXECUTE",
385+
Type: schema.TypeString,
386+
Required: true,
387+
ForceNew: true,
388+
DiffSuppressFunc: tpgresource.CompareCaseInsensitive,
389+
Description: "The taint effect. Possible values: EFFECT_UNSPECIFIED, NO_SCHEDULE, PREFER_NO_SCHEDULE, NO_EXECUTE",
388390
},
389391

390392
"key": {

0 commit comments

Comments
 (0)