Skip to content

Commit 70df53c

Browse files
committed
Implement better logic to detect when a cluster is an EKS cluster
1 parent ece6404 commit 70df53c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

internal/utils/kubernetes.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package utils
22

33
import (
44
"log"
5+
"net/url"
56
"os"
67
"path/filepath"
78
"strings"
@@ -46,8 +47,13 @@ func K8sClient() *kubernetes.Clientset {
4647
return k8sClient
4748
}
4849

50+
// IsEKS determines if the cluster in the current context does appear to be an EKS cluster
4951
func IsEKS() bool {
50-
return strings.Contains(getConfig().Host, ".eks.amazonaws.com")
52+
parsedUrl, err := url.Parse(getConfig().Host)
53+
if err != nil {
54+
return false
55+
}
56+
return strings.HasSuffix(parsedUrl.Host, ".eks.amazonaws.com")
5157
}
5258

5359
func GetEKSClusterName() string {

0 commit comments

Comments
 (0)