Skip to content

Commit

Permalink
remove compute API usage in third_party/validator/compute_instance.go
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
yukinying authored and modular-magician committed Aug 14, 2019
1 parent 64375af commit d8964a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
14 changes: 6 additions & 8 deletions google/resource_compute_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -641,13 +641,11 @@ func getDisk(diskUri string, d *schema.ResourceData, config *Config) (*compute.D
return disk, err
}

func expandComputeInstance(project string, zone *compute.Zone, d *schema.ResourceData, config *Config) (*computeBeta.Instance, error) {
func expandComputeInstance(project string, d *schema.ResourceData, config *Config) (*computeBeta.Instance, error) {
// Get the machine type
var machineTypeUrl string
if mt, ok := d.GetOk("machine_type"); ok {
log.Printf("[DEBUG] Loading machine type: %s", mt.(string))
machineType, err := config.clientCompute.MachineTypes.Get(
project, zone.Name, mt.(string)).Do()
machineType, err := ParseMachineTypesFieldValue(mt.(string), d, config)
if err != nil {
return nil, fmt.Errorf(
"Error loading machine type: %s",
Expand All @@ -660,15 +658,15 @@ func expandComputeInstance(project string, zone *compute.Zone, d *schema.Resourc

disks := []*computeBeta.AttachedDisk{}
if _, hasBootDisk := d.GetOk("boot_disk"); hasBootDisk {
bootDisk, err := expandBootDisk(d, config, zone, project)
bootDisk, err := expandBootDisk(d, config, project)
if err != nil {
return nil, err
}
disks = append(disks, bootDisk)
}

if _, hasScratchDisk := d.GetOk("scratch_disk"); hasScratchDisk {
scratchDisks, err := expandScratchDisks(d, config, zone, project)
scratchDisks, err := expandScratchDisks(d, config, project)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -1601,7 +1599,7 @@ func resourceComputeInstanceImportState(d *schema.ResourceData, meta interface{}
return []*schema.ResourceData{d}, nil
}

func expandBootDisk(d *schema.ResourceData, config *Config, zone *compute.Zone, project string) (*computeBeta.AttachedDisk, error) {
func expandBootDisk(d *schema.ResourceData, config *Config, project string) (*computeBeta.AttachedDisk, error) {
disk := &computeBeta.AttachedDisk{
AutoDelete: d.Get("boot_disk.0.auto_delete").(bool),
Boot: true,
Expand Down Expand Up @@ -1714,7 +1712,7 @@ func flattenBootDisk(d *schema.ResourceData, disk *computeBeta.AttachedDisk, con
return []map[string]interface{}{result}
}

func expandScratchDisks(d *schema.ResourceData, config *Config, zone *compute.Zone, project string) ([]*computeBeta.AttachedDisk, error) {
func expandScratchDisks(d *schema.ResourceData, config *Config, project string) ([]*computeBeta.AttachedDisk, error) {
diskType, err := readDiskType(config, d, "local-ssd")
if err != nil {
return nil, fmt.Errorf("Error loading disk type 'local-ssd': %s", err)
Expand Down
1 change: 1 addition & 0 deletions google/resource_sql_database_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"

sqladmin "google.golang.org/api/sqladmin/v1beta4"
)

Expand Down

0 comments on commit d8964a7

Please sign in to comment.