Skip to content

Commit 795be8e

Browse files
modular-magicianrileykarson
authored andcommitted
Remove beta fields from GA Container resources (#2601)
<!-- This change is generated by MagicModules. --> /cc @rileykarson
1 parent 259c82b commit 795be8e

File tree

3 files changed

+18
-267
lines changed

3 files changed

+18
-267
lines changed

google/node_config.go

+18-64
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ var schemaNodeConfig = &schema.Schema{
142142
},
143143

144144
"taint": {
145-
Deprecated: "This field is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
145+
Removed: "This field is in beta. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
146146
Type: schema.TypeList,
147147
Optional: true,
148148
ForceNew: true,
@@ -170,11 +170,11 @@ var schemaNodeConfig = &schema.Schema{
170170
},
171171

172172
"workload_metadata_config": {
173-
Deprecated: "This field is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
174-
Type: schema.TypeList,
175-
Optional: true,
176-
ForceNew: true,
177-
MaxItems: 1,
173+
Removed: "This field is in beta. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
174+
Type: schema.TypeList,
175+
Optional: true,
176+
ForceNew: true,
177+
MaxItems: 1,
178178
Elem: &schema.Resource{
179179
Schema: map[string]*schema.Schema{
180180
"node_metadata": {
@@ -283,28 +283,6 @@ func expandNodeConfig(v interface{}) *containerBeta.NodeConfig {
283283
nc.MinCpuPlatform = v.(string)
284284
}
285285

286-
if v, ok := nodeConfig["taint"]; ok && len(v.([]interface{})) > 0 {
287-
taints := v.([]interface{})
288-
nodeTaints := make([]*containerBeta.NodeTaint, 0, len(taints))
289-
for _, raw := range taints {
290-
data := raw.(map[string]interface{})
291-
taint := &containerBeta.NodeTaint{
292-
Key: data["key"].(string),
293-
Value: data["value"].(string),
294-
Effect: data["effect"].(string),
295-
}
296-
nodeTaints = append(nodeTaints, taint)
297-
}
298-
nc.Taints = nodeTaints
299-
}
300-
301-
if v, ok := nodeConfig["workload_metadata_config"]; ok && len(v.([]interface{})) > 0 {
302-
conf := v.([]interface{})[0].(map[string]interface{})
303-
nc.WorkloadMetadataConfig = &containerBeta.WorkloadMetadataConfig{
304-
NodeMetadata: conf["node_metadata"].(string),
305-
}
306-
}
307-
308286
return nc
309287
}
310288

@@ -316,20 +294,18 @@ func flattenNodeConfig(c *containerBeta.NodeConfig) []map[string]interface{} {
316294
}
317295

318296
config = append(config, map[string]interface{}{
319-
"machine_type": c.MachineType,
320-
"disk_size_gb": c.DiskSizeGb,
321-
"disk_type": c.DiskType,
322-
"guest_accelerator": flattenContainerGuestAccelerators(c.Accelerators),
323-
"local_ssd_count": c.LocalSsdCount,
324-
"service_account": c.ServiceAccount,
325-
"metadata": c.Metadata,
326-
"image_type": c.ImageType,
327-
"labels": c.Labels,
328-
"tags": c.Tags,
329-
"preemptible": c.Preemptible,
330-
"min_cpu_platform": c.MinCpuPlatform,
331-
"taint": flattenTaints(c.Taints),
332-
"workload_metadata_config": flattenWorkloadMetadataConfig(c.WorkloadMetadataConfig),
297+
"machine_type": c.MachineType,
298+
"disk_size_gb": c.DiskSizeGb,
299+
"disk_type": c.DiskType,
300+
"guest_accelerator": flattenContainerGuestAccelerators(c.Accelerators),
301+
"local_ssd_count": c.LocalSsdCount,
302+
"service_account": c.ServiceAccount,
303+
"metadata": c.Metadata,
304+
"image_type": c.ImageType,
305+
"labels": c.Labels,
306+
"tags": c.Tags,
307+
"preemptible": c.Preemptible,
308+
"min_cpu_platform": c.MinCpuPlatform,
333309
})
334310

335311
if len(c.OauthScopes) > 0 {
@@ -350,28 +326,6 @@ func flattenContainerGuestAccelerators(c []*containerBeta.AcceleratorConfig) []m
350326
return result
351327
}
352328

353-
func flattenTaints(c []*containerBeta.NodeTaint) []map[string]interface{} {
354-
result := []map[string]interface{}{}
355-
for _, taint := range c {
356-
result = append(result, map[string]interface{}{
357-
"key": taint.Key,
358-
"value": taint.Value,
359-
"effect": taint.Effect,
360-
})
361-
}
362-
return result
363-
}
364-
365-
func flattenWorkloadMetadataConfig(c *containerBeta.WorkloadMetadataConfig) []map[string]interface{} {
366-
result := []map[string]interface{}{}
367-
if c != nil {
368-
result = append(result, map[string]interface{}{
369-
"node_metadata": c.NodeMetadata,
370-
})
371-
}
372-
return result
373-
}
374-
375329
func taintDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
376330
if strings.HasSuffix(k, "#") {
377331
oldCount, oldErr := strconv.Atoi(old)

google/resource_container_cluster_test.go

-95
Original file line numberDiff line numberDiff line change
@@ -658,52 +658,6 @@ func TestAccContainerCluster_withNodeConfigScopeAlias(t *testing.T) {
658658
})
659659
}
660660

661-
func TestAccContainerCluster_withNodeConfigTaints(t *testing.T) {
662-
t.Parallel()
663-
664-
resource.Test(t, resource.TestCase{
665-
PreCheck: func() { testAccPreCheck(t) },
666-
Providers: testAccProviders,
667-
CheckDestroy: testAccCheckContainerClusterDestroy,
668-
Steps: []resource.TestStep{
669-
{
670-
Config: testAccContainerCluster_withNodeConfigTaints(),
671-
Check: resource.ComposeTestCheckFunc(
672-
resource.TestCheckResourceAttr("google_container_cluster.with_node_config", "node_config.0.taint.#", "2"),
673-
),
674-
},
675-
// Don't include an import step because beta features can't yet be imported.
676-
// Once taints are in GA, consider merging this test with the _withNodeConfig test.
677-
},
678-
})
679-
}
680-
681-
func TestAccContainerCluster_withWorkloadMetadataConfig(t *testing.T) {
682-
t.Parallel()
683-
684-
resource.Test(t, resource.TestCase{
685-
PreCheck: func() { testAccPreCheck(t) },
686-
Providers: testAccProviders,
687-
CheckDestroy: testAccCheckContainerClusterDestroy,
688-
Steps: []resource.TestStep{
689-
{
690-
Config: testAccContainerCluster_withWorkloadMetadataConfig(),
691-
Check: resource.ComposeTestCheckFunc(
692-
resource.TestCheckResourceAttr("google_container_cluster.with_workload_metadata_config",
693-
"node_config.0.workload_metadata_config.0.node_metadata", "SECURE"),
694-
),
695-
},
696-
{
697-
ResourceName: "google_container_cluster.with_workload_metadata_config",
698-
ImportStateIdPrefix: "us-central1-a/",
699-
ImportState: true,
700-
ImportStateVerify: true,
701-
ImportStateVerifyIgnore: []string{"min_master_version"},
702-
},
703-
},
704-
})
705-
}
706-
707661
func TestAccContainerCluster_network(t *testing.T) {
708662
t.Parallel()
709663

@@ -1760,55 +1714,6 @@ resource "google_container_cluster" "with_node_config_scope_alias" {
17601714
}`, acctest.RandString(10))
17611715
}
17621716

1763-
func testAccContainerCluster_withNodeConfigTaints() string {
1764-
return fmt.Sprintf(`
1765-
resource "google_container_cluster" "with_node_config" {
1766-
name = "cluster-test-%s"
1767-
zone = "us-central1-f"
1768-
initial_node_count = 1
1769-
1770-
node_config {
1771-
taint {
1772-
key = "taint_key"
1773-
value = "taint_value"
1774-
effect = "PREFER_NO_SCHEDULE"
1775-
}
1776-
taint {
1777-
key = "taint_key2"
1778-
value = "taint_value2"
1779-
effect = "NO_EXECUTE"
1780-
}
1781-
}
1782-
}`, acctest.RandString(10))
1783-
}
1784-
1785-
func testAccContainerCluster_withWorkloadMetadataConfig() string {
1786-
return fmt.Sprintf(`
1787-
data "google_container_engine_versions" "central1a" {
1788-
zone = "us-central1-a"
1789-
}
1790-
1791-
resource "google_container_cluster" "with_workload_metadata_config" {
1792-
name = "cluster-test-%s"
1793-
zone = "us-central1-a"
1794-
initial_node_count = 1
1795-
min_master_version = "${data.google_container_engine_versions.central1a.latest_master_version}"
1796-
node_version = "${data.google_container_engine_versions.central1a.latest_node_version}"
1797-
1798-
node_config {
1799-
oauth_scopes = [
1800-
"https://www.googleapis.com/auth/logging.write",
1801-
"https://www.googleapis.com/auth/monitoring"
1802-
]
1803-
1804-
workload_metadata_config {
1805-
node_metadata = "SECURE"
1806-
}
1807-
}
1808-
}
1809-
`, acctest.RandString(10))
1810-
}
1811-
18121717
func testAccContainerCluster_networkRef() string {
18131718
return fmt.Sprintf(`
18141719
resource "google_compute_network" "container_network" {

google/resource_container_node_pool_test.go

-108
Original file line numberDiff line numberDiff line change
@@ -91,55 +91,6 @@ func TestAccContainerNodePool_withNodeConfig(t *testing.T) {
9191
})
9292
}
9393

94-
func TestAccContainerNodePool_withNodeConfigTaints(t *testing.T) {
95-
t.Parallel()
96-
97-
resource.Test(t, resource.TestCase{
98-
PreCheck: func() { testAccPreCheck(t) },
99-
Providers: testAccProviders,
100-
CheckDestroy: testAccCheckContainerNodePoolDestroy,
101-
Steps: []resource.TestStep{
102-
resource.TestStep{
103-
Config: testAccContainerNodePool_withNodeConfigTaints(),
104-
Check: resource.ComposeTestCheckFunc(
105-
resource.TestCheckResourceAttr("google_container_node_pool.np_with_node_config", "node_config.0.taint.#", "2"),
106-
),
107-
},
108-
// Don't include an import step because beta features can't yet be imported.
109-
// Once taints are in GA, consider merging this test with the _withNodeConfig test.
110-
},
111-
})
112-
}
113-
114-
func TestAccContainerNodePool_withWorkloadMetadataConfig(t *testing.T) {
115-
t.Parallel()
116-
117-
resource.Test(t, resource.TestCase{
118-
PreCheck: func() { testAccPreCheck(t) },
119-
Providers: testAccProviders,
120-
CheckDestroy: testAccCheckContainerClusterDestroy,
121-
Steps: []resource.TestStep{
122-
{
123-
Config: testAccContainerNodePool_withWorkloadMetadataConfig(),
124-
Check: resource.ComposeTestCheckFunc(
125-
resource.TestCheckResourceAttr("google_container_node_pool.with_workload_metadata_config",
126-
"node_config.0.workload_metadata_config.0.node_metadata", "SECURE"),
127-
),
128-
},
129-
{
130-
ResourceName: "google_container_node_pool.with_workload_metadata_config",
131-
ImportState: true,
132-
ImportStateVerify: true,
133-
// Import always uses the v1 API, so beta features don't get imported.
134-
ImportStateVerifyIgnore: []string{
135-
"node_config.0.workload_metadata_config.#",
136-
"node_config.0.workload_metadata_config.0.node_metadata",
137-
},
138-
},
139-
},
140-
})
141-
}
142-
14394
func TestAccContainerNodePool_withGPU(t *testing.T) {
14495
t.Parallel()
14596

@@ -707,65 +658,6 @@ resource "google_container_node_pool" "np_with_node_config" {
707658
}`, cluster, nodePool)
708659
}
709660

710-
func testAccContainerNodePool_withNodeConfigTaints() string {
711-
return fmt.Sprintf(`
712-
resource "google_container_cluster" "cluster" {
713-
name = "tf-cluster-nodepool-test-%s"
714-
zone = "us-central1-a"
715-
initial_node_count = 1
716-
}
717-
resource "google_container_node_pool" "np_with_node_config" {
718-
name = "tf-nodepool-test-%s"
719-
zone = "us-central1-a"
720-
cluster = "${google_container_cluster.cluster.name}"
721-
initial_node_count = 1
722-
node_config {
723-
taint {
724-
key = "taint_key"
725-
value = "taint_value"
726-
effect = "PREFER_NO_SCHEDULE"
727-
}
728-
taint {
729-
key = "taint_key2"
730-
value = "taint_value2"
731-
effect = "NO_EXECUTE"
732-
}
733-
}
734-
}`, acctest.RandString(10), acctest.RandString(10))
735-
}
736-
737-
func testAccContainerNodePool_withWorkloadMetadataConfig() string {
738-
return fmt.Sprintf(`
739-
data "google_container_engine_versions" "central1a" {
740-
zone = "us-central1-a"
741-
}
742-
743-
resource "google_container_cluster" "cluster" {
744-
name = "tf-cluster-nodepool-test-%s"
745-
zone = "us-central1-a"
746-
initial_node_count = 1
747-
min_master_version = "${data.google_container_engine_versions.central1a.latest_master_version}"
748-
}
749-
750-
resource "google_container_node_pool" "with_workload_metadata_config" {
751-
name = "tf-nodepool-test-%s"
752-
zone = "us-central1-a"
753-
cluster = "${google_container_cluster.cluster.name}"
754-
initial_node_count = 1
755-
node_config {
756-
oauth_scopes = [
757-
"https://www.googleapis.com/auth/logging.write",
758-
"https://www.googleapis.com/auth/monitoring"
759-
]
760-
761-
workload_metadata_config {
762-
node_metadata = "SECURE"
763-
}
764-
}
765-
}
766-
`, acctest.RandString(10), acctest.RandString(10))
767-
}
768-
769661
func testAccContainerNodePool_withGPU() string {
770662
return fmt.Sprintf(`
771663
data "google_container_engine_versions" "central1c" {

0 commit comments

Comments
 (0)