Skip to content

Commit adad869

Browse files
committed
Revert the fix in user_credentials.go back
1 parent c5c42b7 commit adad869

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pkg/cloud/user_credentials.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ func (c *client) ResolveDomain(domain *Domain) error {
7474
tokens = append([]string{rootDomain}, tokens...)
7575
} else {
7676
tokens[0] = rootDomain
77+
domain.Path = strings.Join(tokens, domainDelimiter)
7778
}
78-
domain.Path = strings.Join(tokens, domainDelimiter)
7979
}
8080

8181
// Set present search/list parameters.
@@ -85,7 +85,7 @@ func (c *client) ResolveDomain(domain *Domain) error {
8585
setIfNotEmpty(domain.ID, p.SetId)
8686

8787
// If path was provided also use level narrow the search for domain.
88-
if level := len(tokens); level >= 0 {
88+
if level := len(tokens) - 1; level >= 0 {
8989
p.SetLevel(level)
9090
}
9191

@@ -140,9 +140,6 @@ func (c *client) ResolveAccount(account *Account) error {
140140
resp, retErr := c.cs.Account.ListAccounts(p)
141141
if retErr != nil {
142142
return retErr
143-
} else if resp.Count == 0 {
144-
return errors.Errorf("could not find account %s in domain ID %s",
145-
account.Name, account.Domain.ID)
146143
} else if resp.Count != 1 {
147144
return errors.Errorf("expected 1 Account with account name %s in domain ID %s, but got %d",
148145
account.Name, account.Domain.ID, resp.Count)
@@ -154,6 +151,11 @@ func (c *client) ResolveAccount(account *Account) error {
154151

155152
// ResolveUser resolves a user's information.
156153
func (c *client) ResolveUser(user *User) error {
154+
// Resolve account prior to any user resolution activity.
155+
if err := c.ResolveAccount(&user.Account); err != nil {
156+
return errors.Wrapf(err, "resolving account %s details", user.Account.Name)
157+
}
158+
157159
p := c.cs.User.NewListUsersParams()
158160
p.SetAccount(user.Account.Name)
159161
p.SetDomainid(user.Domain.ID)
@@ -181,7 +183,7 @@ func (c *client) ResolveUserKeys(user *User) error {
181183
p := c.cs.User.NewGetUserKeysParams(user.ID)
182184
resp, err := c.cs.User.GetUserKeys(p)
183185
if err != nil {
184-
return errors.Wrapf(err, "error encountered when resolving user api keys for user %s", user.Name)
186+
return errors.Errorf("error encountered when resolving user api keys for user %s", user.Name)
185187
}
186188
user.APIKey = resp.Apikey
187189
user.SecretKey = resp.Secretkey

0 commit comments

Comments
 (0)