Skip to content

Commit 92fb1c3

Browse files
fix - remove unnecessary deserialization in codefresh_user activation (#166)
## What ## Why ## Notes <!-- Add any notes here --> ## Checklist * [ ] _I have read [CONTRIBUTING.md](https://github.com/codefresh-io/terraform-provider-codefresh/blob/master/CONTRIBUTING.md)._ * [ ] _I have [allowed changes to my fork to be made](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork)._ * [ ] _I have added tests, assuming new tests are warranted_. * [ ] _I understand that the `/test` comment will be ignored by the CI trigger [unless it is made by a repo admin or collaborator](https://codefresh.io/docs/docs/pipelines/triggers/git-triggers/#support-for-building-pull-requests-from-forks)._
1 parent 88eb8fc commit 92fb1c3

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

codefresh/cfclient/api_key.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@ func (client *Client) createRandomUser(accountId string) (string, error) {
347347
userID := user.ID
348348

349349
// activate
350-
_, err = client.ActivateUser(userID)
350+
err = client.ActivateUser(userID)
351+
351352
if err != nil {
352353
return "", err
353354
}

codefresh/cfclient/user.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,27 +166,20 @@ func (client *Client) AddUserToTeamByAdmin(userID string, accountID string, team
166166
return err
167167
}
168168

169-
func (client *Client) ActivateUser(userId string) (*User, error) {
169+
func (client *Client) ActivateUser(userId string) error {
170170

171171
opts := RequestOptions{
172172
Path: fmt.Sprintf("/admin/user/%s/activate", userId),
173173
Method: "POST",
174174
}
175175

176-
resp, err := client.RequestAPI(&opts)
177-
178-
if err != nil {
179-
return nil, err
180-
}
181-
182-
var user User
176+
_, err := client.RequestAPI(&opts)
183177

184-
err = DecodeResponseInto(resp, &user)
185178
if err != nil {
186-
return nil, err
179+
return err
187180
}
188181

189-
return &user, nil
182+
return nil
190183
}
191184

192185
func (client *Client) SetUserAsAccountAdmin(accountId, userId string) error {

codefresh/resource_account_user_association_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ func testAccCodefreshActivateUser(s *terraform.State, email string) error {
2424
}
2525
for _, user := range currentAccount.Users {
2626
if user.Email == email {
27-
_, err = c.ActivateUser(user.ID)
27+
err = c.ActivateUser(user.ID)
28+
2829
if err != nil {
2930
return fmt.Errorf("failed to activate user: %s", err)
3031
}

codefresh/resource_user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func resourceUsersCreate(d *schema.ResourceData, meta interface{}) error {
157157
}
158158

159159
if d.Get("activate").(bool) {
160-
_, err := client.ActivateUser(d.Id())
160+
err := client.ActivateUser(d.Id())
161161

162162
if err != nil {
163163
return err

0 commit comments

Comments
 (0)