Skip to content

Commit

Permalink
fix importing of tf resource
Browse files Browse the repository at this point in the history
  • Loading branch information
chrissng committed Sep 6, 2019
1 parent 6d4da33 commit 60eb12f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 23 deletions.
2 changes: 1 addition & 1 deletion products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@ objects:
- !ruby/object:Api::Resource
name: 'DiskResourcePolicyAttachment'
input: true
base_url: projects/{{project}}/zones/{{zone}}/disks
base_url: projects/{{project}}/zones/{{zone}}/disks/{{disk}}
create_verb: :POST
create_url: projects/{{project}}/zones/{{zone}}/disks/{{disk}}/addResourcePolicies
delete_verb: :POST
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,2 @@
config := meta.(*Config)
project, err := getProject(d, config)
if err != nil {
return nil, err
}

zone := d.Get("zone").(string)
region := zone[:len(zone)-2]

name := d.Get("name")

if v, ok := res["name"]; ok {
selfLink := fmt.Sprintf("https://www.googleapis.com/compute/v1/projects/%s/regions/%s/resourcePolicies/%s", project, region, name)
if selfLink == v {
res["name"] = name
}
}

res["name"] = GetResourceNameFromSelfLink(res["name"].(string))
return res, nil
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ if err != nil {
return nil, err
}

zone := d.Get("zone").(string)
region := zone[:len(zone)-2]
region := getRegionFromZone(d.Get("zone").(string))

obj["resourcePolicies"] = []interface{}{fmt.Sprintf("projects/%s/regions/%s/resourcePolicies/%s", project, region, obj["name"])}
delete(obj, "name")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
obj = make(map[string]interface{})

// projects/{project}/regions/{region}/resourcePolicies/{resourceId}
zone := d.Get("zone").(string)
region := zone[:len(zone)-2]
region := getRegionFromZone(d.Get("zone").(string))

name, err := expandComputeDiskResourcePolicyAttachmentName(d.Get("name"), d, config)
if err != nil {
Expand Down

0 comments on commit 60eb12f

Please sign in to comment.