INNER CODE UNIT · Go

getClusterInfo

FairwindsOps/rbac-lookup · lookup/gke.go:39

func getClusterInfo(c *clientcmdapi.Config, kubeContext string) *gkeClusterInfo {
	context := c.Contexts[c.CurrentContext]
	if kubeContext != "" {
		context = c.Contexts[kubeContext]
	}

	ci := gkeClusterInfo{}

	if context != nil && context.Cluster != "" {
		s := strings.Split(context.Cluster, "_")
		if s[0] == "gke" {
			ci.ClusterName = s[3]
			ci.Region = s[2]
			ci.ParsedProjectName = s[1]
		}
	}

	return &ci

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…