Documentation ¶
Index ¶
- Constants
- Variables
- func BuildClientGetter(namespace string, opts ...ClientGetterOption) (genericclioptions.RESTClientGetter, error)
- func ConfigFromSecret(secret *corev1.Secret, key string) ([]byte, error)
- func NewInClusterRESTClientGetter(namespace, impersonateAccount, impersonateNamespace string, ...) (genericclioptions.RESTClientGetter, error)
- func NewMemoryRESTClientGetter(kubeConfig []byte, namespace string, impersonateAccount string, ...) genericclioptions.RESTClientGetter
- func SetImpersonationConfig(cfg *rest.Config, namespace, serviceAccount string) string
- func WithClientOptions(opts client.Options) func(o *clientGetterOptions)
- func WithImpersonate(accountName, namespace string) func(o *clientGetterOptions)
- func WithKubeConfig(kubeConfig []byte, opts client.KubeConfigOptions) func(o *clientGetterOptions)
- type ClientGetterOption
- type MemoryRESTClientGetter
- func (c *MemoryRESTClientGetter) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)
- func (c *MemoryRESTClientGetter) ToRESTConfig() (*rest.Config, error)
- func (c *MemoryRESTClientGetter) ToRESTMapper() (meta.RESTMapper, error)
- func (c *MemoryRESTClientGetter) ToRawKubeConfigLoader() clientcmd.ClientConfig
Constants ¶
const ( // DefaultKubeConfigSecretKey is the default data key ConfigFromSecret // looks at when no data key is provided. DefaultKubeConfigSecretKey = "value" // DefaultKubeConfigSecretKeyExt is the default data key ConfigFromSecret // looks at when no data key is provided, and DefaultKubeConfigSecretKey // does not exist. DefaultKubeConfigSecretKeyExt = DefaultKubeConfigSecretKey + ".yaml" )
Variables ¶
var DefaultServiceAccountName string
DefaultServiceAccountName can be set at runtime to enable a fallback account name when no service account name is provided to SetImpersonationConfig.
Functions ¶
func BuildClientGetter ¶ added in v0.22.0
func BuildClientGetter(namespace string, opts ...ClientGetterOption) (genericclioptions.RESTClientGetter, error)
BuildClientGetter builds a genericclioptions.RESTClientGetter based on the provided options and returns the result. Namespace is not expected to be empty. In case it fails to construct using NewInClusterRESTClientGetter, it returns an error.
func ConfigFromSecret ¶ added in v0.22.0
ConfigFromSecret returns the KubeConfig data from the provided key in the given Secret, or attempts to load the data from the default `value` and `value.yaml` keys. If a Secret is provided but no key with data can be found, an error is returned. The secret may be nil, in which case no bytes nor error are returned. Validation of the data is expected to happen while decoding the bytes.
func NewInClusterRESTClientGetter ¶
func NewInClusterRESTClientGetter(namespace, impersonateAccount, impersonateNamespace string, opts *client.Options) (genericclioptions.RESTClientGetter, error)
NewInClusterRESTClientGetter creates a new genericclioptions.RESTClientGetter using genericclioptions.NewConfigFlags, and configures it with the server, authentication, impersonation, client options, and the provided namespace. It returns an error if it fails to retrieve a rest.Config.
func NewMemoryRESTClientGetter ¶
func NewMemoryRESTClientGetter( kubeConfig []byte, namespace string, impersonateAccount string, impersonateNamespace string, clientOpts client.Options, kubeConfigOpts client.KubeConfigOptions) genericclioptions.RESTClientGetter
NewMemoryRESTClientGetter returns a MemoryRESTClientGetter configured with the provided values and client.KubeConfigOptions. The provided KubeConfig is sanitized, configure the settings for this using client.KubeConfigOptions.
func SetImpersonationConfig ¶ added in v0.22.0
SetImpersonationConfig configures the provided service account name if given, or the DefaultServiceAccountName as a fallback if set. It returns the configured impersonation username, or an empty string.
func WithClientOptions ¶ added in v0.22.0
WithClientOptions configures the genericclioptions.RESTClientGetter with provided options.
func WithImpersonate ¶ added in v0.22.0
func WithImpersonate(accountName, namespace string) func(o *clientGetterOptions)
WithImpersonate configures the genericclioptions.RESTClientGetter to impersonate with the given account name in the provided namespace. If the account name is empty, DefaultServiceAccountName is assumed.
func WithKubeConfig ¶ added in v0.22.0
func WithKubeConfig(kubeConfig []byte, opts client.KubeConfigOptions) func(o *clientGetterOptions)
WithKubeConfig creates a MemoryRESTClientGetter configured with the provided KubeConfig and other values.
Types ¶
type ClientGetterOption ¶ added in v0.22.0
type ClientGetterOption func(o *clientGetterOptions)
ClientGetterOption configures a genericclioptions.RESTClientGetter.
type MemoryRESTClientGetter ¶
type MemoryRESTClientGetter struct {
// contains filtered or unexported fields
}
MemoryRESTClientGetter is an implementation of the genericclioptions.RESTClientGetter, capable of working with an in-memory kubeconfig file.
func (*MemoryRESTClientGetter) ToDiscoveryClient ¶
func (c *MemoryRESTClientGetter) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)
ToDiscoveryClient returns a discovery.CachedDiscoveryInterface configured with ToRESTConfig, and the QPS and Burst settings.
func (*MemoryRESTClientGetter) ToRESTConfig ¶
func (c *MemoryRESTClientGetter) ToRESTConfig() (*rest.Config, error)
ToRESTConfig creates a rest.Config with the rest.ImpersonationConfig configured with to the impersonation account. It loads the config the KubeConfig bytes and sanitizes it using the client.KubeConfigOptions.
func (*MemoryRESTClientGetter) ToRESTMapper ¶
func (c *MemoryRESTClientGetter) ToRESTMapper() (meta.RESTMapper, error)
ToRESTMapper returns a RESTMapper constructed from ToDiscoveryClient.
func (*MemoryRESTClientGetter) ToRawKubeConfigLoader ¶
func (c *MemoryRESTClientGetter) ToRawKubeConfigLoader() clientcmd.ClientConfig
ToRawKubeConfigLoader returns a clientcmd.ClientConfig using clientcmd.DefaultClientConfig. With clientcmd.ClusterDefaults, namespace, and impersonate configured as overwrites.