Skip to content

Commit e376147

Browse files
Remove SchemaConfigModeAttr (#11506) (#8011)
[upstream:93bcf85b934cdfdc5d45ae2f876118ab8dd8d3e9] Signed-off-by: Modular Magician <[email protected]>
1 parent 04b789c commit e376147

13 files changed

+37
-359
lines changed

.changelog/11506.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
```release-note:breaking-change
2+
composer: `ip_allocation_policy = []` in `google_composer_environment` is no longer valid configuration. Removing the field from configuration should not produce a diff.
3+
```
4+
```release-note:breaking-change
5+
compute: `secondary_ip_ranges = []` in `google_compute_subnetwork` is no longer valid configuration. To set an explicitly empty list, use `send_secondary_ip_range_if_empty` and completely remove `secondary_ip_range` from config.
6+
```
7+
```release-note:breaking-change
8+
compute: `guest_accelerator = []` is no longer valid configuration in `google_compute_instance`. To explicitly set an empty list of objects, set guest_accelerator.count = 0.
9+
```
10+
```release-note:breaking-change
11+
compute: `google_compute_instance_from_template` and `google_compute_instance_from_machine_image` `network_interface.alias_ip_range, network_interface.access_config, attached_disk, guest_accelerator, service_account, scratch_disk` can no longer be set to an empty block `[]`. Removing the fields from configuration should not produce a diff.
12+
```
13+
```release-note:breaking-change
14+
container: `guest_accelerator = []` is no longer valid configuration in `google_container_cluster` and `google_container_node_pool`. To explicitly set an empty list of objects, set guest_accelerator.count = 0.
15+
```
16+
```release-note:breaking-change
17+
container: `guest_accelerator.gpu_driver_installation_config = []` and `guest_accelerator.gpu_sharing_config = []` are no longer valid configuration in `google_container_cluster` and `google_container_node_pool`. Removing the fields from configuration should not produce a diff.
18+
```

google-beta/services/composer/resource_composer_environment.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ func ResourceComposerEnvironment() *schema.Resource {
315315
Optional: true,
316316
Computed: true,
317317
ForceNew: true,
318-
ConfigMode: schema.SchemaConfigModeAttr,
319318
MaxItems: 1,
320319
Description: `Configuration for controlling how IPs are allocated in the GKE cluster. Cannot be updated.`,
321320
Elem: &schema.Resource{

google-beta/services/compute/resource_compute_instance.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,6 @@ func ResourceComputeInstance() *schema.Resource {
655655
Optional: true,
656656
Computed: true,
657657
ForceNew: true,
658-
ConfigMode: schema.SchemaConfigModeAttr,
659658
Description: `List of the type and count of accelerator cards attached to the instance.`,
660659
Elem: &schema.Resource{
661660
Schema: map[string]*schema.Schema{

google-beta/services/compute/resource_compute_instance_from_machine_image.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,6 @@ func computeInstanceFromMachineImageSchema() map[string]*schema.Schema {
4343
s[field].Optional = true
4444
}
4545

46-
// schema.SchemaConfigModeAttr allows these fields to be removed in Terraform 0.12.
47-
// Passing field_name = [] in this mode differentiates between an intentionally empty
48-
// block vs an ignored computed block.
49-
nic := s["network_interface"].Elem.(*schema.Resource)
50-
nic.Schema["alias_ip_range"].ConfigMode = schema.SchemaConfigModeAttr
51-
nic.Schema["access_config"].ConfigMode = schema.SchemaConfigModeAttr
52-
53-
for _, field := range []string{"attached_disk", "guest_accelerator", "service_account", "scratch_disk"} {
54-
s[field].ConfigMode = schema.SchemaConfigModeAttr
55-
}
56-
5746
recurseOnSchema(s, func(field *schema.Schema) {
5847
// We don't want to accidentally use default values to override the instance
5948
// machine image, so remove defaults.

google-beta/services/compute/resource_compute_instance_from_template.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,6 @@ func computeInstanceFromTemplateSchema() map[string]*schema.Schema {
4848
s[field].Optional = true
4949
}
5050

51-
// schema.SchemaConfigModeAttr allows these fields to be removed in Terraform 0.12.
52-
// Passing field_name = [] in this mode differentiates between an intentionally empty
53-
// block vs an ignored computed block.
54-
nic := s["network_interface"].Elem.(*schema.Resource)
55-
nic.Schema["alias_ip_range"].ConfigMode = schema.SchemaConfigModeAttr
56-
nic.Schema["access_config"].ConfigMode = schema.SchemaConfigModeAttr
57-
58-
for _, field := range []string{"attached_disk", "guest_accelerator", "service_account", "scratch_disk"} {
59-
s[field].ConfigMode = schema.SchemaConfigModeAttr
60-
}
61-
6251
// Remove deprecated/removed fields that are never d.Set. We can't
6352
// programmatically remove all of them, because some of them still have d.Set
6453
// calls.

google-beta/services/compute/resource_compute_instance_from_template_test.go

Lines changed: 0 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -365,49 +365,6 @@ func TestAccComputeInstanceFromTemplate_overrideScheduling(t *testing.T) {
365365
})
366366
}
367367

368-
func TestAccComputeInstanceFromTemplate_012_removableFields(t *testing.T) {
369-
t.Parallel()
370-
371-
var instance compute.Instance
372-
instanceName := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10))
373-
templateName := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10))
374-
resourceName := "google_compute_instance_from_template.inst"
375-
376-
// First config is a basic instance from template, second tests the empty list syntax
377-
config1 := testAccComputeInstanceFromTemplate_012_removableFieldsTpl(templateName) +
378-
testAccComputeInstanceFromTemplate_012_removableFields1(instanceName)
379-
config2 := testAccComputeInstanceFromTemplate_012_removableFieldsTpl(templateName) +
380-
testAccComputeInstanceFromTemplate_012_removableFields2(instanceName)
381-
382-
acctest.VcrTest(t, resource.TestCase{
383-
PreCheck: func() { acctest.AccTestPreCheck(t) },
384-
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
385-
CheckDestroy: testAccCheckComputeInstanceFromTemplateDestroyProducer(t),
386-
Steps: []resource.TestStep{
387-
{
388-
Config: config1,
389-
Check: resource.ComposeTestCheckFunc(
390-
testAccCheckComputeInstanceExists(t, resourceName, &instance),
391-
392-
resource.TestCheckResourceAttr(resourceName, "service_account.#", "1"),
393-
resource.TestCheckResourceAttr(resourceName, "service_account.0.scopes.#", "3"),
394-
),
395-
},
396-
{
397-
Config: config2,
398-
Check: resource.ComposeTestCheckFunc(
399-
testAccCheckComputeInstanceExists(t, resourceName, &instance),
400-
401-
// Check that fields were able to be removed
402-
resource.TestCheckResourceAttr(resourceName, "scratch_disk.#", "0"),
403-
resource.TestCheckResourceAttr(resourceName, "attached_disk.#", "0"),
404-
resource.TestCheckResourceAttr(resourceName, "network_interface.0.alias_ip_range.#", "0"),
405-
),
406-
},
407-
},
408-
})
409-
}
410-
411368
func TestAccComputeInstanceFromTemplate_overrideMetadataDotStartupScript(t *testing.T) {
412369
var instance compute.Instance
413370
instanceName := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10))
@@ -1473,84 +1430,6 @@ resource "google_compute_instance_from_template" "inst" {
14731430
`, templateDisk, template, instance)
14741431
}
14751432

1476-
func testAccComputeInstanceFromTemplate_012_removableFieldsTpl(template string) string {
1477-
1478-
return fmt.Sprintf(`
1479-
data "google_compute_image" "my_image" {
1480-
family = "debian-11"
1481-
project = "debian-cloud"
1482-
}
1483-
1484-
resource "google_compute_instance_template" "foobar" {
1485-
name = "%s"
1486-
machine_type = "e2-medium"
1487-
1488-
disk {
1489-
source_image = data.google_compute_image.my_image.self_link
1490-
auto_delete = true
1491-
disk_size_gb = 20
1492-
boot = true
1493-
}
1494-
1495-
network_interface {
1496-
network = "default"
1497-
}
1498-
1499-
metadata = {
1500-
foo = "bar"
1501-
}
1502-
1503-
service_account {
1504-
scopes = ["userinfo-email", "compute-ro", "storage-ro"]
1505-
}
1506-
1507-
can_ip_forward = true
1508-
}
1509-
`, template)
1510-
}
1511-
1512-
func testAccComputeInstanceFromTemplate_012_removableFields1(instance string) string {
1513-
return fmt.Sprintf(`
1514-
resource "google_compute_instance_from_template" "inst" {
1515-
name = "%s"
1516-
zone = "us-central1-a"
1517-
1518-
allow_stopping_for_update = true
1519-
1520-
source_instance_template = google_compute_instance_template.foobar.self_link
1521-
}
1522-
`, instance)
1523-
}
1524-
1525-
func testAccComputeInstanceFromTemplate_012_removableFields2(instance string) string {
1526-
return fmt.Sprintf(`
1527-
resource "google_compute_instance_from_template" "inst" {
1528-
name = "%s"
1529-
zone = "us-central1-a"
1530-
1531-
allow_stopping_for_update = true
1532-
1533-
source_instance_template = google_compute_instance_template.foobar.self_link
1534-
1535-
// Overrides
1536-
network_interface {
1537-
alias_ip_range = []
1538-
}
1539-
1540-
service_account = []
1541-
1542-
scratch_disk = []
1543-
1544-
attached_disk = []
1545-
1546-
timeouts {
1547-
create = "10m"
1548-
update = "10m"
1549-
}
1550-
}
1551-
`, instance)
1552-
}
1553-
15541433
func testAccComputeInstanceFromTemplate_overrideMetadataDotStartupScript(instance, template string) string {
15551434
return fmt.Sprintf(`
15561435
data "google_compute_image" "my_image" {

google-beta/services/compute/resource_compute_instance_test.go

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,20 +1733,6 @@ func TestAccComputeInstance_guestAcceleratorSkip(t *testing.T) {
17331733
testAccCheckComputeInstanceLacksGuestAccelerator(&instance),
17341734
),
17351735
},
1736-
// Recreate with guest_accelerator = []
1737-
{
1738-
Config: testAccComputeInstance_guestAcceleratorEmptyBlock(instanceName),
1739-
Check: resource.ComposeTestCheckFunc(
1740-
testAccCheckComputeInstanceExists(t, "google_compute_instance.foobar", &instance),
1741-
testAccCheckComputeInstanceLacksGuestAccelerator(&instance),
1742-
),
1743-
},
1744-
// Check that count = 0 is the same as empty block []
1745-
{
1746-
Config: testAccComputeInstance_guestAccelerator(instanceName, 0),
1747-
ExpectNonEmptyPlan: false,
1748-
PlanOnly: true,
1749-
},
17501736
},
17511737
})
17521738

@@ -7117,38 +7103,6 @@ resource "google_compute_instance" "foobar" {
71177103
`, instance, count)
71187104
}
71197105

7120-
func testAccComputeInstance_guestAcceleratorEmptyBlock(instance string) string {
7121-
return fmt.Sprintf(`
7122-
data "google_compute_image" "my_image" {
7123-
family = "debian-11"
7124-
project = "debian-cloud"
7125-
}
7126-
7127-
resource "google_compute_instance" "foobar" {
7128-
name = "%s"
7129-
machine_type = "n1-standard-1" // can't be e2 because of guest_accelerator
7130-
zone = "us-east1-d"
7131-
7132-
boot_disk {
7133-
initialize_params {
7134-
image = data.google_compute_image.my_image.self_link
7135-
}
7136-
}
7137-
7138-
network_interface {
7139-
network = "default"
7140-
}
7141-
7142-
scheduling {
7143-
# Instances with guest accelerators do not support live migration.
7144-
on_host_maintenance = "TERMINATE"
7145-
}
7146-
7147-
guest_accelerator = []
7148-
}
7149-
`, instance)
7150-
}
7151-
71527106
func testAccComputeInstance_minCpuPlatform(instance string) string {
71537107
return fmt.Sprintf(`
71547108
data "google_compute_image" "my_image" {

google-beta/services/compute/resource_compute_subnetwork.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,9 @@ An 'ACTIVE' subnetwork is one that is currently being used for Envoy-based load
292292
A 'BACKUP' subnetwork is one that is ready to be promoted to 'ACTIVE' or is currently draining. Possible values: ["ACTIVE", "BACKUP"]`,
293293
},
294294
"secondary_ip_range": {
295-
Type: schema.TypeList,
296-
Computed: true,
297-
Optional: true,
298-
ConfigMode: schema.SchemaConfigModeAttr,
295+
Type: schema.TypeList,
296+
Computed: true,
297+
Optional: true,
299298
Description: `An array of configurations for secondary IP ranges for VM instances
300299
contained in this subnetwork. The primary IP of such VM must belong
301300
to the primary ipCidrRange of the subnetwork. The alias IPs may belong

google-beta/services/compute/resource_compute_subnetwork_test.go

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,6 @@ func TestAccComputeSubnetwork_secondaryIpRanges(t *testing.T) {
185185
testAccCheckComputeSubnetworkHasSecondaryIpRange(&subnetwork, "tf-test-secondary-range-update2", "192.168.11.0/24"),
186186
),
187187
},
188-
{
189-
Config: testAccComputeSubnetwork_secondaryIpRanges_update4(cnName, subnetworkName),
190-
Check: resource.ComposeTestCheckFunc(
191-
testAccCheckComputeSubnetworkExists(t, "google_compute_subnetwork.network-with-private-secondary-ip-ranges", &subnetwork),
192-
testAccCheckComputeSubnetworkHasNotSecondaryIpRange(&subnetwork, "tf-test-secondary-range-update1", "192.168.10.0/24"),
193-
testAccCheckComputeSubnetworkHasNotSecondaryIpRange(&subnetwork, "tf-test-secondary-range-update2", "192.168.11.0/24"),
194-
),
195-
},
196188
{
197189
Config: testAccComputeSubnetwork_secondaryIpRanges_update1(cnName, subnetworkName),
198190
Check: resource.ComposeTestCheckFunc(
@@ -241,12 +233,6 @@ func TestAccComputeSubnetwork_secondaryIpRanges_sendEmpty(t *testing.T) {
241233
testAccCheckComputeSubnetworkHasNotSecondaryIpRange(&subnetwork, "tf-test-secondary-range-update1", "192.168.10.0/24"),
242234
),
243235
},
244-
// Check that empty block secondary_ip_range = [] is not different
245-
{
246-
Config: testAccComputeSubnetwork_sendEmpty_emptyBlock(cnName, subnetworkName, "true"),
247-
PlanOnly: true,
248-
ExpectNonEmptyPlan: false,
249-
},
250236
// Apply two secondary_ip_range
251237
{
252238
Config: testAccComputeSubnetwork_sendEmpty_double(cnName, subnetworkName, "true"),
@@ -279,14 +265,6 @@ func TestAccComputeSubnetwork_secondaryIpRanges_sendEmpty(t *testing.T) {
279265
PlanOnly: true,
280266
ExpectNonEmptyPlan: false,
281267
},
282-
// Remove with empty block []
283-
{
284-
Config: testAccComputeSubnetwork_sendEmpty_emptyBlock(cnName, subnetworkName, "true"),
285-
Check: resource.ComposeTestCheckFunc(
286-
testAccCheckComputeSubnetworkExists(t, "google_compute_subnetwork.network-with-private-secondary-ip-ranges", &subnetwork),
287-
testAccCheckComputeSubnetworkHasNotSecondaryIpRange(&subnetwork, "tf-test-secondary-range-update1", "192.168.10.0/24"),
288-
),
289-
},
290268
},
291269
})
292270
}
@@ -688,23 +666,6 @@ resource "google_compute_subnetwork" "network-with-private-secondary-ip-ranges"
688666
`, cnName, subnetworkName)
689667
}
690668

691-
func testAccComputeSubnetwork_secondaryIpRanges_update4(cnName, subnetworkName string) string {
692-
return fmt.Sprintf(`
693-
resource "google_compute_network" "custom-test" {
694-
name = "%s"
695-
auto_create_subnetworks = false
696-
}
697-
698-
resource "google_compute_subnetwork" "network-with-private-secondary-ip-ranges" {
699-
name = "%s"
700-
ip_cidr_range = "10.2.0.0/16"
701-
region = "us-central1"
702-
network = google_compute_network.custom-test.self_link
703-
secondary_ip_range = []
704-
}
705-
`, cnName, subnetworkName)
706-
}
707-
708669
func testAccComputeSubnetwork_sendEmpty_removed(cnName, subnetworkName, sendEmpty string) string {
709670
return fmt.Sprintf(`
710671
resource "google_compute_network" "custom-test" {
@@ -722,24 +683,6 @@ resource "google_compute_subnetwork" "network-with-private-secondary-ip-ranges"
722683
`, cnName, subnetworkName, sendEmpty)
723684
}
724685

725-
func testAccComputeSubnetwork_sendEmpty_emptyBlock(cnName, subnetworkName, sendEmpty string) string {
726-
return fmt.Sprintf(`
727-
resource "google_compute_network" "custom-test" {
728-
name = "%s"
729-
auto_create_subnetworks = false
730-
}
731-
732-
resource "google_compute_subnetwork" "network-with-private-secondary-ip-ranges" {
733-
name = "%s"
734-
ip_cidr_range = "10.2.0.0/16"
735-
region = "us-central1"
736-
network = google_compute_network.custom-test.self_link
737-
secondary_ip_range = []
738-
send_secondary_ip_range_if_empty = "%s"
739-
}
740-
`, cnName, subnetworkName, sendEmpty)
741-
}
742-
743686
func testAccComputeSubnetwork_sendEmpty_single(cnName, subnetworkName, sendEmpty string) string {
744687
return fmt.Sprintf(`
745688
resource "google_compute_network" "custom-test" {

0 commit comments

Comments
 (0)