Add Bearer token

Signed-off-by: Dmitry Makovey <dmakovey@gitlab.com>
pull/1891/head
Dmitry Makovey 2 years ago
parent daba16f4be
commit b986ce566b

@ -23,6 +23,7 @@ type EndpointMeta struct {
AuthProvider *clientcmdapi.AuthProviderConfig `json:",omitempty"` AuthProvider *clientcmdapi.AuthProviderConfig `json:",omitempty"`
Exec *clientcmdapi.ExecConfig `json:",omitempty"` Exec *clientcmdapi.ExecConfig `json:",omitempty"`
UsernamePassword *UsernamePassword `json:"usernamePassword,omitempty"` UsernamePassword *UsernamePassword `json:"usernamePassword,omitempty"`
Token string `json:"token,omitempty"`
} }
// UsernamePassword contains username/password auth info // UsernamePassword contains username/password auth info
@ -77,6 +78,9 @@ func (c *Endpoint) KubernetesConfig() clientcmd.ClientConfig {
authInfo.Username = c.UsernamePassword.Username authInfo.Username = c.UsernamePassword.Username
authInfo.Password = c.UsernamePassword.Password authInfo.Password = c.UsernamePassword.Password
} }
if c.Token != "" {
authInfo.Token = c.Token
}
authInfo.AuthProvider = c.AuthProvider authInfo.AuthProvider = c.AuthProvider
authInfo.Exec = c.Exec authInfo.Exec = c.Exec
cfg.Clusters["cluster"] = cluster cfg.Clusters["cluster"] = cluster

@ -68,6 +68,7 @@ func FromKubeConfig(kubeconfig, kubeContext, namespaceOverride string) (Endpoint
AuthProvider: clientcfg.AuthProvider, AuthProvider: clientcfg.AuthProvider,
Exec: clientcfg.ExecProvider, Exec: clientcfg.ExecProvider,
UsernamePassword: usernamePassword, UsernamePassword: usernamePassword,
Token: clientcfg.BearerToken,
}, },
TLSData: tlsData, TLSData: tlsData,
}, nil }, nil

Loading…
Cancel
Save