Skip to content

Commit

Permalink
Ignore host when searching for postgres sql user in read from list (#849
Browse files Browse the repository at this point in the history
)

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored and emilymye committed Jun 17, 2019
1 parent 9afde22 commit 7175929
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions google-beta/resource_sql_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,13 @@ func resourceSqlUserRead(d *schema.ResourceData, meta interface{}) error {

var user *sqladmin.User
for _, currentUser := range users.Items {
// The second part of this conditional is irrelevant for postgres instances because
// host and currentUser.Host will always both be empty.
if currentUser.Name == name && currentUser.Host == host {
user = currentUser
break
if currentUser.Name == name {
// Host can only be empty for postgres instances,
// so don't compare the host if the API host is empty.
if currentUser.Host == "" || currentUser.Host == host {
user = currentUser
break
}
}
}

Expand Down

0 comments on commit 7175929

Please sign in to comment.