mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-07-17 00:41:18 +00:00
Merge pull request #65 from k8sgpt-ai/feat/bugfix-auth
feat: fixes a nasty bug
This commit is contained in:
commit
cc562a0380
@ -24,9 +24,13 @@ var AuthCmd = &cobra.Command{
|
|||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
|
||||||
backendType := viper.GetString("backend_type")
|
backendType := viper.GetString("backend_type")
|
||||||
if backendType == "" && backend == "" {
|
if backendType == "" {
|
||||||
color.Red("No backend set. Please run k8sgpt auth")
|
// Set the default backend
|
||||||
os.Exit(1)
|
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
|
// override the default backend if a flag is provided
|
||||||
if backend != "" {
|
if backend != "" {
|
||||||
|
@ -13,10 +13,10 @@ type OpenAIClient struct {
|
|||||||
|
|
||||||
func (c *OpenAIClient) Configure(token string) error {
|
func (c *OpenAIClient) Configure(token string) error {
|
||||||
client := openai.NewClient(token)
|
client := openai.NewClient(token)
|
||||||
|
|
||||||
if client == nil {
|
if client == nil {
|
||||||
return errors.New("error creating OpenAI client")
|
return errors.New("error creating OpenAI client")
|
||||||
}
|
}
|
||||||
|
c.client = client
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user