@@ -70,11 +70,10 @@ func (c *client) ResolveDomain(domain *Domain) error {
70
70
domain .Name = tokens [len (tokens )- 1 ]
71
71
}
72
72
// Ensure the path begins with ROOT.
73
- if ! strings .EqualFold (tokens [0 ], rootDomain ) {
73
+ if strings .EqualFold (tokens [0 ], rootDomain ) {
74
74
tokens = append ([]string {rootDomain }, tokens ... )
75
75
} else {
76
- tokens [0 ] = rootDomain
77
- domain .Path = strings .Join (tokens , domainDelimiter )
76
+ domain .Path = rootDomain + domainDelimiter + strings .Join (tokens , domainDelimiter )
78
77
}
79
78
}
80
79
@@ -85,7 +84,7 @@ func (c *client) ResolveDomain(domain *Domain) error {
85
84
setIfNotEmpty (domain .ID , p .SetId )
86
85
87
86
// 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 {
89
88
p .SetLevel (level )
90
89
}
91
90
@@ -154,11 +153,6 @@ func (c *client) ResolveAccount(account *Account) error {
154
153
155
154
// ResolveUser resolves a user's information.
156
155
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
-
162
156
p := c .cs .User .NewListUsersParams ()
163
157
p .SetAccount (user .Account .Name )
164
158
p .SetDomainid (user .Domain .ID )
@@ -186,7 +180,7 @@ func (c *client) ResolveUserKeys(user *User) error {
186
180
p := c .cs .User .NewGetUserKeysParams (user .ID )
187
181
resp , err := c .cs .User .GetUserKeys (p )
188
182
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 )
190
184
}
191
185
user .APIKey = resp .Apikey
192
186
user .SecretKey = resp .Secretkey
0 commit comments