Skip to content

Commit

Permalink
[Terraform]: Remove inferred zone from region on Disk import (#1073)
Browse files Browse the repository at this point in the history
Merged PR #1073.
  • Loading branch information
rileykarson authored and modular-magician committed Dec 17, 2018
1 parent d19648f commit 9fb55a9
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 52 deletions.
1 change: 0 additions & 1 deletion products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ overrides: !ruby/object:Provider::ResourceOverrides
These images can be referred by family name here.
custom_code: !ruby/object:Provider::Terraform::CustomCode
pre_delete: templates/terraform/pre_delete/detach_disk.erb
post_import: templates/terraform/post_import/disk.erb
constants: templates/terraform/constants/disk.erb
encoder: templates/terraform/encoders/disk.erb
extra_schema_entry: templates/terraform/extra_schema_entry/disk.erb
Expand Down
26 changes: 0 additions & 26 deletions templates/terraform/post_import/disk.erb

This file was deleted.

25 changes: 0 additions & 25 deletions third_party/terraform/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/hashicorp/errwrap"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"google.golang.org/api/compute/v1"
"google.golang.org/api/googleapi"
)

Expand Down Expand Up @@ -62,30 +61,6 @@ func getProjectFromDiff(d *schema.ResourceDiff, config *Config) (string, error)
return "", fmt.Errorf("%s: required field is not set", "project")
}

func getZonalResourceFromRegion(getResource func(string) (interface{}, error), region string, compute *compute.Service, project string) (interface{}, error) {
zoneList, err := compute.Zones.List(project).Do()
if err != nil {
return nil, err
}
var resource interface{}
for _, zone := range zoneList.Items {
if strings.Contains(zone.Name, region) {
resource, err = getResource(zone.Name)
if err != nil {
if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 {
// Resource was not found in this zone
continue
}
return nil, fmt.Errorf("Error reading Resource: %s", err)
}
// Resource was found
return resource, nil
}
}
// Resource does not exist in this region
return nil, nil
}

func getRouterLockName(region string, router string) string {
return fmt.Sprintf("router/%s/%s", region, router)
}
Expand Down

0 comments on commit 9fb55a9

Please sign in to comment.