From 70df53ca5987262d6440de10af992379811577e3 Mon Sep 17 00:00:00 2001 From: Christophe Tafani-Dereeper Date: Thu, 1 Jun 2023 10:24:32 +0200 Subject: [PATCH] Implement better logic to detect when a cluster is an EKS cluster --- internal/utils/kubernetes.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/utils/kubernetes.go b/internal/utils/kubernetes.go index 0946647..41cb8e9 100644 --- a/internal/utils/kubernetes.go +++ b/internal/utils/kubernetes.go @@ -2,6 +2,7 @@ package utils import ( "log" + "net/url" "os" "path/filepath" "strings" @@ -46,8 +47,13 @@ func K8sClient() *kubernetes.Clientset { return k8sClient } +// IsEKS determines if the cluster in the current context does appear to be an EKS cluster func IsEKS() bool { - return strings.Contains(getConfig().Host, ".eks.amazonaws.com") + parsedUrl, err := url.Parse(getConfig().Host) + if err != nil { + return false + } + return strings.HasSuffix(parsedUrl.Host, ".eks.amazonaws.com") } func GetEKSClusterName() string {