Skip to content

Commit

Permalink
Revert "Fix version behaviour in google_compute_instance_group (Goo…
Browse files Browse the repository at this point in the history
…gleCloudPlatform#2506)"

This reverts commit d59ec0f.
  • Loading branch information
JanMa authored Oct 25, 2019
1 parent f544bd4 commit 02e864e
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 39 deletions.
2 changes: 1 addition & 1 deletion build/terraform-mapper
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,10 @@ func resourceComputeInstanceGroup() *schema.Resource {
},

"network": {
Type: schema.TypeString,
Optional: true,
Computed: true,
DiffSuppressFunc: compareSelfLinkOrResourceName,
ForceNew: true,
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

"project": {
Expand Down
30 changes: 30 additions & 0 deletions third_party/terraform/resources/resource_compute_target_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,36 @@ func resourceComputeTargetPoolCreate(d *schema.ResourceData, meta interface{}) e
return resourceComputeTargetPoolRead(d, meta)
}

func calcAddRemove(from []string, to []string) ([]string, []string) {
add := make([]string, 0)
remove := make([]string, 0)
for _, u := range to {
found := false
for _, v := range from {
if u == v {
found = true
break
}
}
if !found {
add = append(add, u)
}
}
for _, u := range from {
found := false
for _, v := range to {
if u == v {
found = true
break
}
}
if !found {
remove = append(remove, u)
}
}
return add, remove
}

func resourceComputeTargetPoolUpdate(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

Expand Down
33 changes: 0 additions & 33 deletions third_party/terraform/utils/utils.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -542,36 +542,3 @@ func getInterconnectAttachmentLink(config *Config, project, region, ic string) (

return ic, nil
}

// Given two sets of references (with "from" values in self link form),
// determine which need to be added or removed // during an update using
// addX/removeX APIs.
func calcAddRemove(from []string, to []string) (add, remove []string) {
add = make([]string, 0)
remove = make([]string, 0)
for _, u := range to {
found := false
for _, v := range from {
if compareSelfLinkOrResourceName("", v, u, nil) {
found = true
break
}
}
if !found {
add = append(add, u)
}
}
for _, u := range from {
found := false
for _, v := range to {
if compareSelfLinkOrResourceName("", u, v, nil) {
found = true
break
}
}
if !found {
remove = append(remove, u)
}
}
return add, remove
}

0 comments on commit 02e864e

Please sign in to comment.