Skip to content

Commit

Permalink
fix(profile/update): ensure SetDefault() is called
Browse files Browse the repository at this point in the history
  • Loading branch information
Integralist committed Sep 15, 2023
1 parent 8601f03 commit f595d0a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/commands/profile/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error {
if err != nil {
return fmt.Errorf("failed to update token: %w", err)
}
} else if makeDefault { // only set default if not updating the token (as updating the token already handles setting the default)
err := c.updateDefault(profileName)
}

if makeDefault {
err := c.setAsDefault(profileName)
if err != nil {
return fmt.Errorf("failed to update token: %w", err)
}
Expand Down Expand Up @@ -169,7 +171,7 @@ func (c *UpdateCommand) updateToken(profileName string, makeDefault bool, p *con
return nil
}

func (c *UpdateCommand) updateDefault(profileName string) error {
func (c *UpdateCommand) setAsDefault(profileName string) error {
p, ok := profile.SetDefault(profileName, c.Globals.Config.Profiles)
if !ok {
return errors.New("failed to update the profile's default field")
Expand Down

0 comments on commit f595d0a

Please sign in to comment.