Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change update verb for apigee_envgroup to patch #9740

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/5047.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
apigee: fixed update behavior on `google_apigee_envgroup`
```
19 changes: 12 additions & 7 deletions google/resource_apigee_envgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,6 @@ func resourceApigeeEnvgroupUpdate(d *schema.ResourceData, meta interface{}) erro
billingProject := ""

obj := make(map[string]interface{})
nameProp, err := expandApigeeEnvgroupName(d.Get("name"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("name"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, nameProp)) {
obj["name"] = nameProp
}
hostnamesProp, err := expandApigeeEnvgroupHostnames(d.Get("hostnames"), d, config)
if err != nil {
return err
Expand All @@ -205,13 +199,24 @@ func resourceApigeeEnvgroupUpdate(d *schema.ResourceData, meta interface{}) erro
}

log.Printf("[DEBUG] Updating Envgroup %q: %#v", d.Id(), obj)
updateMask := []string{}

if d.HasChange("hostnames") {
updateMask = append(updateMask, "hostnames")
}
// updateMask is a URL parameter but not present in the schema, so replaceVars
// won't set it
url, err = addQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")})
if err != nil {
return err
}

// err == nil indicates that the billing_project value was found
if bp, err := getBillingProject(d, config); err == nil {
billingProject = bp
}

res, err := sendRequestWithTimeout(config, "PUT", billingProject, url, userAgent, obj, d.Timeout(schema.TimeoutUpdate))
res, err := sendRequestWithTimeout(config, "PATCH", billingProject, url, userAgent, obj, d.Timeout(schema.TimeoutUpdate))

if err != nil {
return fmt.Errorf("Error updating Envgroup %q: %s", d.Id(), err)
Expand Down