From f595d0aaee41946b90283c885ff6262769b8e8e1 Mon Sep 17 00:00:00 2001 From: Integralist Date: Fri, 15 Sep 2023 12:19:19 +0100 Subject: [PATCH] fix(profile/update): ensure SetDefault() is called --- pkg/commands/profile/update.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/commands/profile/update.go b/pkg/commands/profile/update.go index 3c1a6f916..548f3412c 100644 --- a/pkg/commands/profile/update.go +++ b/pkg/commands/profile/update.go @@ -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) } @@ -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")