Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrTokenExpirationOutOfRange = errors.New("the KubernetesTokenSourceConfig.TokenExpiration needs to be at least 10m") ErrServiceAccountMissing = errors.New("make sure the ServiceAccount property is set") )
Functions ¶
func NewKubernetesTokenSource ¶
func NewKubernetesTokenSource(cfg *rest.Config, opts *KubernetesTokenSourceConfig) (*kubernetesTokenSource, error)
Generates a new KubernetesTokenSource which can be used in combination with the golang.org/x/oauth2 package as it implements the https://pkg.go.dev/golang.org/x/oauth2#TokenSource interface.
It will take care of automatically refreshing the credential whenever needed, so that the client that consumes this TokenSource has always an up to date credential available.
Types ¶
type KubernetesTokenSourceConfig ¶
type KubernetesTokenSourceConfig struct { // Audiences which should be applied to the generated token. Audiences []string // ServiceAccount identifies the service account which shall be impersonated when creating the TokenRequest ServiceAccount types.NamespacedName // Determines how long the credential generated via the TokenRequest API is valid for. // Needs to be at least 10 mins. It defaults to 1h. TokenExpiration time.Duration }
Click to show internal directories.
Click to hide internal directories.