From b986ce566b3c2df63254a6cf9e89892ea12ac7d1 Mon Sep 17 00:00:00 2001 From: Dmitry Makovey Date: Fri, 16 Jun 2023 08:49:12 -0600 Subject: [PATCH] Add Bearer token Signed-off-by: Dmitry Makovey --- driver/kubernetes/context/load.go | 4 ++++ driver/kubernetes/context/save.go | 1 + 2 files changed, 5 insertions(+) diff --git a/driver/kubernetes/context/load.go b/driver/kubernetes/context/load.go index d6a23d85..0882962e 100644 --- a/driver/kubernetes/context/load.go +++ b/driver/kubernetes/context/load.go @@ -23,6 +23,7 @@ type EndpointMeta struct { AuthProvider *clientcmdapi.AuthProviderConfig `json:",omitempty"` Exec *clientcmdapi.ExecConfig `json:",omitempty"` UsernamePassword *UsernamePassword `json:"usernamePassword,omitempty"` + Token string `json:"token,omitempty"` } // UsernamePassword contains username/password auth info @@ -77,6 +78,9 @@ func (c *Endpoint) KubernetesConfig() clientcmd.ClientConfig { authInfo.Username = c.UsernamePassword.Username authInfo.Password = c.UsernamePassword.Password } + if c.Token != "" { + authInfo.Token = c.Token + } authInfo.AuthProvider = c.AuthProvider authInfo.Exec = c.Exec cfg.Clusters["cluster"] = cluster diff --git a/driver/kubernetes/context/save.go b/driver/kubernetes/context/save.go index 7eb346bd..2b1ec1f4 100644 --- a/driver/kubernetes/context/save.go +++ b/driver/kubernetes/context/save.go @@ -68,6 +68,7 @@ func FromKubeConfig(kubeconfig, kubeContext, namespaceOverride string) (Endpoint AuthProvider: clientcfg.AuthProvider, Exec: clientcfg.ExecProvider, UsernamePassword: usernamePassword, + Token: clientcfg.BearerToken, }, TLSData: tlsData, }, nil