Skip to content

Commit

Permalink
Enhanced EKSSupport.GetContextName by implementing support for when t…
Browse files Browse the repository at this point in the history
…he current context name is the cluster name
  • Loading branch information
James Stronz committed Sep 19, 2024
1 parent c331dcc commit 6398510
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cloudsupport/v1/ekssupport.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,10 @@ func (eksSupport *EKSSupport) GetRegion(cluster string) (string, error) {
return region, nil
}

// Context can be in one of 2 ways:
// Context can be in one of 3 ways:
// 1. arn:aws:eks:<region>:<id>:cluster/<cluster_name> --> Usually this will be in context
// 2. arn:aws:eks:<region>:<id>:cluster-<cluster_name> --> Usually we will get 'cluster' param like this
// 3. <cluster_name> --> Context name is the cluster name
func (eksSupport *EKSSupport) GetContextName(cluster string) string {
if cluster != "" {
splittedCluster := strings.Split(cluster, ".")
Expand Down Expand Up @@ -170,6 +171,11 @@ func (eksSupport *EKSSupport) GetContextName(cluster string) string {
// arn:aws:eks:<region>:<id>:cluster/<cluster_name> -> <cluster_name>
return splittedCluster[len(splittedCluster)-1]
}

if cluster != "" && k8sinterface.GetContextName() == cluster {
return cluster
}

return ""
}

Expand Down

0 comments on commit 6398510

Please sign in to comment.