Skip to content

Commit f858639

Browse files
committed
fix nil-dereference if active cluster refers to non-existing cluster entry
1 parent e94dd35 commit f858639

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

config.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ type Config struct {
2828
}
2929

3030
func (c *Config) SetCurrentCluster(name string) error {
31-
oldCluster := c.ActiveCluster().Name
31+
var oldCluster string
32+
if c.ActiveCluster() != nil {
33+
oldCluster = c.ActiveCluster().Name
34+
}
3235
for _, cluster := range c.Clusters {
3336
if cluster.Name == name {
3437
c.CurrentCluster = name

0 commit comments

Comments
 (0)