Skip to content

Commit

Permalink
fix: use of specified context to obtain cluster name (#339)
Browse files Browse the repository at this point in the history
Signed-off-by: chenk <[email protected]>
  • Loading branch information
chen-keinan authored May 7, 2024
1 parent f31b54a commit f6c5fb0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/k8s/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,12 @@ func (c *cluster) ClusterNameVersion() (string, string, error) {
}
clusterName := "k8s.io/kubernetes"
if len(rawCfg.Contexts) > 0 {
clusterName = rawCfg.Contexts[rawCfg.CurrentContext].Cluster
if c.currentContext != "" {
rawCfg.CurrentContext = c.currentContext
}
if clusterContext, ok := rawCfg.Contexts[rawCfg.CurrentContext]; ok {
clusterName = clusterContext.Cluster
}
}
version, err := c.clientset.ServerVersion()
if err != nil {
Expand Down

0 comments on commit f6c5fb0

Please sign in to comment.