fix panics

This commit is contained in:
Enrico Candino 2024-02-08 10:09:15 +01:00
parent 2cc3438cba
commit 49f30d1d26
No known key found for this signature in database
GPG Key ID: D1B9BC7875F6191A
2 changed files with 9 additions and 2 deletions

View File

@ -280,6 +280,9 @@ func cacheCredential(ctx *cli.Context, cred *config.ExecCredential, id string) e
return err
}
if sc.KubeCredentials[id] == nil {
sc.KubeCredentials = make(map[string]*config.ExecCredential)
}
sc.KubeCredentials[id] = cred
cf.Servers[server] = sc
return cf.Write()

View File

@ -71,8 +71,12 @@ func serverCurrent(ctx *cli.Context) error {
}
serverName := cf.CurrentServer
URL := cf.Servers[serverName].URL
fmt.Printf("Name: %s URL: %s\n", serverName, URL)
currentServer, found := cf.Servers[serverName]
if !found {
return errors.New("Current server not set")
}
fmt.Printf("Name: %s URL: %s\n", serverName, currentServer.URL)
return nil
}