Skip to content

Commit

Permalink
Merge pull request #65 from k8sgpt-ai/feat/bugfix-auth
Browse files Browse the repository at this point in the history
feat: fixes a nasty bug
  • Loading branch information
AlexsJones committed Mar 24, 2023
2 parents c7e8f00 + 80a9975 commit cc562a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions cmd/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ var AuthCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {

backendType := viper.GetString("backend_type")
if backendType == "" && backend == "" {
color.Red("No backend set. Please run k8sgpt auth")
os.Exit(1)
if backendType == "" {
// Set the default backend
viper.Set("backend_type", "openai")
if err := viper.WriteConfig(); err != nil {
color.Red("Error writing config file: %s", err.Error())
os.Exit(1)
}
}
// override the default backend if a flag is provided
if backend != "" {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ai/ai.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ type OpenAIClient struct {

func (c *OpenAIClient) Configure(token string) error {
client := openai.NewClient(token)

if client == nil {
return errors.New("error creating OpenAI client")
}
c.client = client
return nil
}

Expand Down

0 comments on commit cc562a0

Please sign in to comment.