kubeconfig

package
v0.34.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2023 License: Apache-2.0 Imports: 11 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// SecretType is used to indicate which kubernetes secrets contain a KubeConfig.
	SecretType = "solo.io/kubeconfig"

	// Key is the KubeConfig's key in the KubeConfig secret data.
	Key = "kubeconfig"
)

Variables

View Source
var (
	FailedToConvertKubeConfigToSecret = func(err error) error {
		return eris.Wrap(err, "Could not serialize KubeConfig to yaml while generating secret.")
	}
	FailedToConvertSecretToKubeConfig = func(err error) error {
		return eris.Wrapf(err, "Could not deserialize string to KubeConfig while generating KubeConfig")
	}
	FailedToConvertSecretToClientConfig = func(err error) error {
		return eris.Wrap(err, "Could not convert config to ClientConfig")
	}
	SecretHasNoKubeConfig = func(meta metav1.ObjectMeta) error {
		return eris.Errorf("kube config secret %s.%s has no KubeConfig value for key %v",
			meta.Namespace, meta.Name, Key)
	}
	FailedToConvertSecretToRestConfig = func(err error) error {
		return eris.Wrap(err, "Could not convert config to *rest.Config")
	}
)
View Source
var (
	FailedToReadCAFile = func(err error, fileName string) error {
		return eris.Wrapf(err, "Failed to read kubeconfig CA file: %s", fileName)
	}
)

Functions

func BuildPredicate added in v0.25.0

func BuildPredicate(watchNamespaces []string) predicate.Funcs

func BuildRemoteCfg

func BuildRemoteCfg(
	remoteCluster *api.Cluster,
	remoteCtx *api.Context,
	clusterName, token string,
) api.Config

func GetClientConfigWithContext added in v0.7.17

func GetClientConfigWithContext(kubeConfigPath, kubeContext, apiServerUrl string) (clientcmd.ClientConfig, error)

Fetch ClientConfig. If kubeConfigPath is not specified, retrieve the kubeconfig from environment in which this is invoked. Override the API Server URL and current context if specified.

func GetRawConfigWithContext added in v0.7.17

func GetRawConfigWithContext(kubeConfigPath, kubeContext, apiServerUrl string) (clientcmdapi.Config, error)

Fetch raw Config for environment in which this is invoked, override the API Server URL and current context if specified.

func GetRestConfigWithContext added in v0.7.17

func GetRestConfigWithContext(kubeConfigPath, kubeContext, apiServerUrl string) (*rest.Config, error)

Fetch rest.Config for environment in which this is invoked, override the API Server URL and current context if specified.

func SecretObjMeta added in v0.7.17

func SecretObjMeta(namespace string, cluster string, resourceLabels map[string]string) metav1.ObjectMeta

func SecretToConfig

func SecretToConfig(secret *kubev1.Secret) (clusterName string, config clientcmd.ClientConfig, err error)

SecretToConfig extracts the cluster name and *Config from a KubeConfig secret. If the provided secret is not a KubeConfig secret, an error is returned.

func ToSecret

func ToSecret(namespace string, cluster string, resourceLabels map[string]string, kc api.Config) (*kubev1.Secret, error)

ToSecret converts a kubernetes api.Config to a secret with the provided cluster as the name and the provided namespace.

Types

type KubeLoader

type KubeLoader interface {
	GetRestConfigForContext(path string, context string) (*rest.Config, error)
	GetRawConfigForContext(path, context string) (clientcmdapi.Config, error)
	GetClientConfigForContext(path, context string) (clientcmd.ClientConfig, error)
	GetRestConfigFromBytes(config []byte) (*rest.Config, error)
}

Directories

Path Synopsis
Package mock_kubeconfig is a generated GoMock package.
Package mock_kubeconfig is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL