Skip to content

Commit efc8423

Browse files
committed
Fix issues with subdomain
1 parent ce1fd35 commit efc8423

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

pkg/cloud/user_credentials.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,10 @@ func (c *client) ResolveDomain(domain *Domain) error {
7070
domain.Name = tokens[len(tokens)-1]
7171
}
7272
// Ensure the path begins with ROOT.
73-
if !strings.EqualFold(tokens[0], rootDomain) {
73+
if strings.EqualFold(tokens[0], rootDomain) {
7474
tokens = append([]string{rootDomain}, tokens...)
7575
} else {
76-
tokens[0] = rootDomain
77-
domain.Path = strings.Join(tokens, domainDelimiter)
76+
domain.Path = rootDomain + domainDelimiter + strings.Join(tokens, domainDelimiter)
7877
}
7978
}
8079

@@ -85,7 +84,7 @@ func (c *client) ResolveDomain(domain *Domain) error {
8584
setIfNotEmpty(domain.ID, p.SetId)
8685

8786
// If path was provided also use level narrow the search for domain.
88-
if level := len(tokens) - 1; level >= 0 {
87+
if level := len(tokens); level >= 0 {
8988
p.SetLevel(level)
9089
}
9190

@@ -154,11 +153,6 @@ func (c *client) ResolveAccount(account *Account) error {
154153

155154
// ResolveUser resolves a user's information.
156155
func (c *client) ResolveUser(user *User) error {
157-
// Resolve account prior to any user resolution activity.
158-
if err := c.ResolveAccount(&user.Account); err != nil {
159-
return errors.Wrapf(err, "resolving account %s details", user.Account.Name)
160-
}
161-
162156
p := c.cs.User.NewListUsersParams()
163157
p.SetAccount(user.Account.Name)
164158
p.SetDomainid(user.Domain.ID)
@@ -186,7 +180,7 @@ func (c *client) ResolveUserKeys(user *User) error {
186180
p := c.cs.User.NewGetUserKeysParams(user.ID)
187181
resp, err := c.cs.User.GetUserKeys(p)
188182
if err != nil {
189-
return errors.Errorf("error encountered when resolving user api keys for user %s", user.Name)
183+
return errors.Wrapf(err, "error encountered when resolving user api keys for user %s", user.Name)
190184
}
191185
user.APIKey = resp.Apikey
192186
user.SecretKey = resp.Secretkey

0 commit comments

Comments
 (0)