Skip to content

Commit 1cbd681

Browse files
modular-magicianslevenick
authored andcommitted
Remove disk interface, tests (#5185) (#3611)
* Remove disk interface tests * Remove region disk test also * Fix api compile * Add DSF to always suppress diff, readd default * Remove unused method from GA Signed-off-by: Modular Magician <[email protected]>
1 parent 0401afb commit 1cbd681

10 files changed

+24
-134
lines changed

.changelog/5185.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:deprecation
2+
compute: deprecated `interface` field on `google_compute_disk` and `google_compute_region_disk` (beta only)
3+
```

google-beta/common_diff_suppress.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,8 @@ func durationDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
182182
}
183183
return oDuration == nDuration
184184
}
185+
186+
// Suppress all diffs, used for Disk.Interface which is a nonfunctional field
187+
func alwaysDiffSuppress(_, _, _ string, _ *schema.ResourceData) bool {
188+
return true
189+
}

google-beta/resource_compute_disk.go

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525

2626
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
2727
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
28-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
2928
"google.golang.org/api/googleapi"
3029
)
3130

@@ -347,12 +346,13 @@ For instance, the image 'centos-6-v20180104' includes its family name 'centos-6'
347346
These images can be referred by family name here.`,
348347
},
349348
"interface": {
350-
Type: schema.TypeString,
351-
Optional: true,
352-
ForceNew: true,
353-
ValidateFunc: validation.StringInSlice([]string{"SCSI", "NVME", ""}, false),
354-
Description: `Specifies the disk interface to use for attaching this disk, which is either SCSI or NVME. The default is SCSI. Default value: "SCSI" Possible values: ["SCSI", "NVME"]`,
355-
Default: "SCSI",
349+
Type: schema.TypeString,
350+
Optional: true,
351+
Deprecated: "This field is no longer in use, disk interfaces will be automatically determined on attachment. To resolve this issue, remove this field from your config.",
352+
ForceNew: true,
353+
DiffSuppressFunc: alwaysDiffSuppress,
354+
Description: `Specifies the disk interface to use for attaching this disk, which is either SCSI or NVME. The default is SCSI.`,
355+
Default: "SCSI",
356356
},
357357
"labels": {
358358
Type: schema.TypeMap,
@@ -646,12 +646,6 @@ func resourceComputeDiskCreate(d *schema.ResourceData, meta interface{}) error {
646646
} else if v, ok := d.GetOkExists("physical_block_size_bytes"); !isEmptyValue(reflect.ValueOf(physicalBlockSizeBytesProp)) && (ok || !reflect.DeepEqual(v, physicalBlockSizeBytesProp)) {
647647
obj["physicalBlockSizeBytes"] = physicalBlockSizeBytesProp
648648
}
649-
interfaceProp, err := expandComputeDiskInterface(d.Get("interface"), d, config)
650-
if err != nil {
651-
return err
652-
} else if v, ok := d.GetOkExists("interface"); !isEmptyValue(reflect.ValueOf(interfaceProp)) && (ok || !reflect.DeepEqual(v, interfaceProp)) {
653-
obj["interface"] = interfaceProp
654-
}
655649
typeProp, err := expandComputeDiskType(d.Get("type"), d, config)
656650
if err != nil {
657651
return err
@@ -840,9 +834,6 @@ func resourceComputeDiskRead(d *schema.ResourceData, meta interface{}) error {
840834
if err := d.Set("physical_block_size_bytes", flattenComputeDiskPhysicalBlockSizeBytes(res["physicalBlockSizeBytes"], d, config)); err != nil {
841835
return fmt.Errorf("Error reading Disk: %s", err)
842836
}
843-
if err := d.Set("interface", flattenComputeDiskInterface(res["interface"], d, config)); err != nil {
844-
return fmt.Errorf("Error reading Disk: %s", err)
845-
}
846837
if err := d.Set("type", flattenComputeDiskType(res["type"], d, config)); err != nil {
847838
return fmt.Errorf("Error reading Disk: %s", err)
848839
}
@@ -1172,14 +1163,6 @@ func flattenComputeDiskPhysicalBlockSizeBytes(v interface{}, d *schema.ResourceD
11721163
return v // let terraform core handle it otherwise
11731164
}
11741165

1175-
func flattenComputeDiskInterface(v interface{}, d *schema.ResourceData, config *Config) interface{} {
1176-
if v == nil || isEmptyValue(reflect.ValueOf(v)) {
1177-
return "SCSI"
1178-
}
1179-
1180-
return v
1181-
}
1182-
11831166
func flattenComputeDiskType(v interface{}, d *schema.ResourceData, config *Config) interface{} {
11841167
if v == nil {
11851168
return v
@@ -1377,10 +1360,6 @@ func expandComputeDiskPhysicalBlockSizeBytes(v interface{}, d TerraformResourceD
13771360
return v, nil
13781361
}
13791362

1380-
func expandComputeDiskInterface(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
1381-
return v, nil
1382-
}
1383-
13841363
func expandComputeDiskType(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
13851364
f, err := parseZonalFieldValue("diskTypes", v.(string), "project", "zone", d, config, true)
13861365
if err != nil {

google-beta/resource_compute_disk_generated_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestAccComputeDisk_diskBasicExample(t *testing.T) {
4242
ResourceName: "google_compute_disk.default",
4343
ImportState: true,
4444
ImportStateVerify: true,
45-
ImportStateVerifyIgnore: []string{"type", "zone", "snapshot"},
45+
ImportStateVerifyIgnore: []string{"interface", "type", "zone", "snapshot"},
4646
},
4747
},
4848
})

google-beta/resource_compute_disk_test.go

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -458,27 +458,6 @@ func TestAccComputeDisk_resourcePolicies(t *testing.T) {
458458
})
459459
}
460460

461-
func TestAccComputeDisk_interface(t *testing.T) {
462-
t.Parallel()
463-
464-
diskName := fmt.Sprintf("tf-test-%s", randString(t, 10))
465-
466-
vcrTest(t, resource.TestCase{
467-
PreCheck: func() { testAccPreCheck(t) },
468-
Providers: testAccProviders,
469-
Steps: []resource.TestStep{
470-
{
471-
Config: testAccComputeDisk_interface(diskName),
472-
},
473-
{
474-
ResourceName: "google_compute_disk.foobar",
475-
ImportState: true,
476-
ImportStateVerify: true,
477-
},
478-
},
479-
})
480-
}
481-
482461
func TestAccComputeDisk_multiWriter(t *testing.T) {
483462
t.Parallel()
484463
instanceName := fmt.Sprintf("tf-test-%s", randString(t, 10))
@@ -817,24 +796,6 @@ resource "google_compute_disk" "foobar" {
817796
`, policyName, diskName)
818797
}
819798

820-
func testAccComputeDisk_interface(diskName string) string {
821-
return fmt.Sprintf(`
822-
data "google_compute_image" "my_image" {
823-
family = "debian-9"
824-
project = "debian-cloud"
825-
}
826-
827-
resource "google_compute_disk" "foobar" {
828-
name = "%s"
829-
image = data.google_compute_image.my_image.self_link
830-
size = 50
831-
type = "pd-ssd"
832-
zone = "us-central1-a"
833-
interface = "NVME"
834-
}
835-
`, diskName)
836-
}
837-
838799
func testAccComputeDisk_multiWriter(instance string, diskName string, enableMultiwriter bool) string {
839800
return fmt.Sprintf(`
840801
data "google_compute_image" "my_image" {

google-beta/resource_compute_region_disk.go

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424

2525
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
2626
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
27-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
2827
"google.golang.org/api/googleapi"
2928
)
3029

@@ -123,12 +122,13 @@ encryption key that protects this resource.`,
123122
},
124123
},
125124
"interface": {
126-
Type: schema.TypeString,
127-
Optional: true,
128-
ForceNew: true,
129-
ValidateFunc: validation.StringInSlice([]string{"SCSI", "NVME", ""}, false),
130-
Description: `Specifies the disk interface to use for attaching this disk, which is either SCSI or NVME. The default is SCSI. Default value: "SCSI" Possible values: ["SCSI", "NVME"]`,
131-
Default: "SCSI",
125+
Type: schema.TypeString,
126+
Optional: true,
127+
Deprecated: "This field is no longer in use, disk interfaces will be automatically determined on attachment. To resolve this issue, remove this field from your config.",
128+
ForceNew: true,
129+
DiffSuppressFunc: alwaysDiffSuppress,
130+
Description: `Specifies the disk interface to use for attaching this disk, which is either SCSI or NVME. The default is SCSI.`,
131+
Default: "SCSI",
132132
},
133133
"labels": {
134134
Type: schema.TypeMap,
@@ -335,12 +335,6 @@ func resourceComputeRegionDiskCreate(d *schema.ResourceData, meta interface{}) e
335335
} else if v, ok := d.GetOkExists("type"); !isEmptyValue(reflect.ValueOf(typeProp)) && (ok || !reflect.DeepEqual(v, typeProp)) {
336336
obj["type"] = typeProp
337337
}
338-
interfaceProp, err := expandComputeRegionDiskInterface(d.Get("interface"), d, config)
339-
if err != nil {
340-
return err
341-
} else if v, ok := d.GetOkExists("interface"); !isEmptyValue(reflect.ValueOf(interfaceProp)) && (ok || !reflect.DeepEqual(v, interfaceProp)) {
342-
obj["interface"] = interfaceProp
343-
}
344338
regionProp, err := expandComputeRegionDiskRegion(d.Get("region"), d, config)
345339
if err != nil {
346340
return err
@@ -499,9 +493,6 @@ func resourceComputeRegionDiskRead(d *schema.ResourceData, meta interface{}) err
499493
if err := d.Set("type", flattenComputeRegionDiskType(res["type"], d, config)); err != nil {
500494
return fmt.Errorf("Error reading RegionDisk: %s", err)
501495
}
502-
if err := d.Set("interface", flattenComputeRegionDiskInterface(res["interface"], d, config)); err != nil {
503-
return fmt.Errorf("Error reading RegionDisk: %s", err)
504-
}
505496
if err := d.Set("region", flattenComputeRegionDiskRegion(res["region"], d, config)); err != nil {
506497
return fmt.Errorf("Error reading RegionDisk: %s", err)
507498
}
@@ -824,14 +815,6 @@ func flattenComputeRegionDiskType(v interface{}, d *schema.ResourceData, config
824815
return NameFromSelfLinkStateFunc(v)
825816
}
826817

827-
func flattenComputeRegionDiskInterface(v interface{}, d *schema.ResourceData, config *Config) interface{} {
828-
if v == nil || isEmptyValue(reflect.ValueOf(v)) {
829-
return "SCSI"
830-
}
831-
832-
return v
833-
}
834-
835818
func flattenComputeRegionDiskRegion(v interface{}, d *schema.ResourceData, config *Config) interface{} {
836819
if v == nil {
837820
return v
@@ -963,10 +946,6 @@ func expandComputeRegionDiskType(v interface{}, d TerraformResourceData, config
963946
return f.RelativeLink(), nil
964947
}
965948

966-
func expandComputeRegionDiskInterface(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
967-
return v, nil
968-
}
969-
970949
func expandComputeRegionDiskRegion(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
971950
f, err := parseGlobalFieldValue("regions", v.(string), "project", d, config, true)
972951
if err != nil {

google-beta/resource_compute_region_disk_generated_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestAccComputeRegionDisk_regionDiskBasicExample(t *testing.T) {
4242
ResourceName: "google_compute_region_disk.regiondisk",
4343
ImportState: true,
4444
ImportStateVerify: true,
45-
ImportStateVerifyIgnore: []string{"type", "region", "snapshot"},
45+
ImportStateVerifyIgnore: []string{"type", "interface", "region", "snapshot"},
4646
},
4747
},
4848
})

google-beta/resource_compute_region_disk_test.go

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -174,39 +174,6 @@ func TestAccComputeRegionDisk_deleteDetach(t *testing.T) {
174174
})
175175
}
176176

177-
func TestAccComputeRegionDisk_interface(t *testing.T) {
178-
t.Parallel()
179-
180-
diskName := fmt.Sprintf("tf-test-%s", randString(t, 10))
181-
182-
vcrTest(t, resource.TestCase{
183-
PreCheck: func() { testAccPreCheck(t) },
184-
Providers: testAccProviders,
185-
Steps: []resource.TestStep{
186-
{
187-
Config: testAccComputeRegionDisk_interface(diskName),
188-
},
189-
{
190-
ResourceName: "google_compute_region_disk.foobar",
191-
ImportState: true,
192-
ImportStateVerify: true,
193-
},
194-
},
195-
})
196-
}
197-
198-
func testAccComputeRegionDisk_interface(diskName string) string {
199-
return fmt.Sprintf(`
200-
resource "google_compute_region_disk" "foobar" {
201-
name = "%s"
202-
size = 50
203-
type = "pd-ssd"
204-
interface = "NVME"
205-
replica_zones = ["us-central1-a", "us-central1-f"]
206-
}
207-
`, diskName)
208-
}
209-
210177
func testAccCheckComputeRegionDiskExists(t *testing.T, n string, disk *computeBeta.Disk) resource.TestCheckFunc {
211178
return func(s *terraform.State) error {
212179
p := getTestProjectFromEnv()

website/docs/r/compute_disk.html.markdown

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ The following arguments are supported:
123123
* `interface` -
124124
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
125125
Specifies the disk interface to use for attaching this disk, which is either SCSI or NVME. The default is SCSI.
126-
Default value is `SCSI`.
127-
Possible values are `SCSI` and `NVME`.
128126

129127
* `type` -
130128
(Optional)

website/docs/r/compute_region_disk.html.markdown

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ The following arguments are supported:
141141
* `interface` -
142142
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
143143
Specifies the disk interface to use for attaching this disk, which is either SCSI or NVME. The default is SCSI.
144-
Default value is `SCSI`.
145-
Possible values are `SCSI` and `NVME`.
146144

147145
* `region` -
148146
(Optional)

0 commit comments

Comments
 (0)