Skip to content

fix - remove unnecessary unmarshalling in codefresh_user activation #166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion codefresh/cfclient/api_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ func (client *Client) createRandomUser(accountId string) (string, error) {
userID := user.ID

// activate
_, err = client.ActivateUser(userID)
err = client.ActivateUser(userID)

if err != nil {
return "", err
}
Expand Down
15 changes: 4 additions & 11 deletions codefresh/cfclient/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,27 +166,20 @@ func (client *Client) AddUserToTeamByAdmin(userID string, accountID string, team
return err
}

func (client *Client) ActivateUser(userId string) (*User, error) {
func (client *Client) ActivateUser(userId string) error {

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

resp, err := client.RequestAPI(&opts)

if err != nil {
return nil, err
}

var user User
_, err := client.RequestAPI(&opts)

err = DecodeResponseInto(resp, &user)
if err != nil {
return nil, err
return err
}

return &user, nil
return nil
}

func (client *Client) SetUserAsAccountAdmin(accountId, userId string) error {
Expand Down
3 changes: 2 additions & 1 deletion codefresh/resource_account_user_association_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ func testAccCodefreshActivateUser(s *terraform.State, email string) error {
}
for _, user := range currentAccount.Users {
if user.Email == email {
_, err = c.ActivateUser(user.ID)
err = c.ActivateUser(user.ID)

if err != nil {
return fmt.Errorf("failed to activate user: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion codefresh/resource_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func resourceUsersCreate(d *schema.ResourceData, meta interface{}) error {
}

if d.Get("activate").(bool) {
_, err := client.ActivateUser(d.Id())
err := client.ActivateUser(d.Id())

if err != nil {
return err
Expand Down
Loading