Skip to content
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

fix(core): nil panic on set-default #304

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 3 additions & 0 deletions cmd/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ var profileSetDefaultCmd = &cobra.Command{
Short: "Set a profile as default",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
// ensure profile is initialized
InitProfile(cmd, false)

profileName := args[0]

print := cli.NewPrinter(true)
Expand Down
10 changes: 7 additions & 3 deletions pkg/profiles/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package profiles

import (
"errors"
"fmt"
)

// TODO:
Expand Down Expand Up @@ -30,9 +31,11 @@ type CurrentProfileStore struct {
config ProfileConfig
}

const PROFILE_DRIVER_KEYRING = "keyring"
const PROFILE_DRIVER_IN_MEMORY = "in-memory"
const PROFILE_DRIVER_DEFAULT = PROFILE_DRIVER_KEYRING
const (
PROFILE_DRIVER_KEYRING = "keyring"
PROFILE_DRIVER_IN_MEMORY = "in-memory"
PROFILE_DRIVER_DEFAULT = PROFILE_DRIVER_KEYRING
)

type profileConfigVariadicFunc func(profileConfig) profileConfig

Expand Down Expand Up @@ -169,6 +172,7 @@ func (p *Profile) UseDefaultProfile() (*ProfileStore, error) {
}

func (p *Profile) SetDefaultProfile(profileName string) error {
fmt.Println(p)
jakedoublev marked this conversation as resolved.
Show resolved Hide resolved
if !p.globalStore.ProfileExists(profileName) {
return errors.New("profile does not exist")
}
Expand Down