Skip to content

Commit

Permalink
feat: use the same user configuration for all contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
Zebradil committed May 17, 2024
1 parent 8f77c79 commit b48a75e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ import (
"github.com/spf13/viper"
)

// Name of the user to use in kubeconfig entries.
// The same user configuration is used for all clusters.
const userName = "gke-kubeconfiger"

type credentialsData struct {
CertificateAuthorityData string
ClusterName string
Expand Down Expand Up @@ -312,9 +316,9 @@ func addCredentialsToKubeconfig(kubeconfig map[string]interface{}, data credenti
})
replaceOrAppend(kubeconfig, "contexts", clusterName, "context", map[string]interface{}{
"cluster": clusterName,
"user": clusterName,
"user": userName,
})
replaceOrAppend(kubeconfig, "users", clusterName, "user", map[string]interface{}{
replaceOrAppend(kubeconfig, "users", userName, "user", map[string]interface{}{
"exec": map[string]interface{}{
"apiVersion": "client.authentication.k8s.io/v1beta1",
"command": "gke-gcloud-auth-plugin",
Expand Down

0 comments on commit b48a75e

Please sign in to comment.