Skip to content

Commit

Permalink
Implement better logic to detect when a cluster is an EKS cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
christophetd committed Jun 1, 2023
1 parent ece6404 commit 70df53c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/utils/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package utils

import (
"log"
"net/url"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 70df53c

Please sign in to comment.