Skip to content

Commit 116fc44

Browse files
committed
Fix typo and set profile if needed in case setProfile is true
1 parent e2702ce commit 116fc44

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

internal/cmd/config/profile/create/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
8888

8989
func configureFlags(cmd *cobra.Command) {
9090
cmd.Flags().Bool(noSetFlag, false, "Do not set the profile as the active profile")
91-
cmd.Flags().Bool(ignoreExistingFlag, false, "Suppress the error it the profile exists already")
91+
cmd.Flags().Bool(ignoreExistingFlag, false, "Suppress the error if the profile exists already")
9292
cmd.Flags().Bool(fromEmptyProfile, false, "Create the profile with the initial default configurations")
9393
}
9494

internal/pkg/config/profiles.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func GetProfileFromEnv() (string, bool) {
7979
// CreateProfile creates a new profile.
8080
// If emptyProfile is true, it creates an empty profile. Otherwise, copies the config from the current profile to the new profile.
8181
// If setProfile is true, it sets the new profile as the active profile.
82-
// If the profile already exists, it returns an error.
82+
// If the profile already exists and ignoreExisting is false, it returns an error.
8383
func CreateProfile(p *print.Printer, profile string, setProfile, ignoreExising, emptyProfile bool) error {
8484
err := ValidateProfile(profile)
8585
if err != nil {
@@ -99,6 +99,12 @@ func CreateProfile(p *print.Printer, profile string, setProfile, ignoreExising,
9999
_, err = os.Stat(configFolderPath)
100100
if err == nil {
101101
if ignoreExising {
102+
if setProfile {
103+
err = SetProfile(p, profile)
104+
if err != nil {
105+
return fmt.Errorf("set profile: %w", err)
106+
}
107+
}
102108
return nil
103109
}
104110
return fmt.Errorf("profile %q already exists", profile)

0 commit comments

Comments
 (0)