Skip to content
Open
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
5 changes: 3 additions & 2 deletions mmv1/products/alloydb/User.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ docs:
base_url: '{{cluster}}/users'
self_link: '{{cluster}}/users/{{user_id}}'
create_url: '{{cluster}}/users?userId={{user_id}}'
update_url: '{{cluster}}/users?userId={{user_id}}'
update_verb: 'POST'
update_verb: 'PATCH'
update_mask: true
import_format:
- 'projects/{{project}}/locations/{{location}}/clusters/{{cluster}}/users/{{user_id}}'
timeouts:
Expand All @@ -33,6 +33,7 @@ timeouts:
autogen_async: true
custom_code:
custom_import: 'templates/terraform/custom_import/alloydb_user.go.tmpl'
pre_update: 'templates/terraform/pre_update/alloydb_user.go.tmpl'
# Skipping the sweeper because instances will be deleted during cluster sweeps
exclude_sweeper: true
examples:
Expand Down
17 changes: 17 additions & 0 deletions mmv1/templates/terraform/pre_update/alloydb_user.go.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// If password_wo_version changed, the user wants to update the password.
// Write-only fields aren't in state, so d.HasChange("password_wo") is always
// false and the value is never added to obj by the generated code. Handle
// both the update mask and the request body here.
if d.HasChange("password_wo_version") {
if pw := tpgresource.GetRawConfigAttributeAsString(d, "password_wo"); pw != "" {
obj["password"] = pw
}
updateMask = append(updateMask, "password")

// Rebuild the updateMask query parameter.
url = strings.Split(url, "?updateMask=")[0]
url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")})
if err != nil {
return err
}
}
Loading