kubeconfig

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2020 License: Apache-2.0 Imports: 13 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)
	}
)
View Source
var Predicate = predicate.Funcs{
	CreateFunc: func(e event.CreateEvent) bool {
		return isKubeConfigSecret(e.Object)
	},
	DeleteFunc: func(e event.DeleteEvent) bool {
		return isKubeConfigSecret(e.Object)
	},
	UpdateFunc: func(e event.UpdateEvent) bool {
		if isKubeConfigSecret(e.ObjectNew) {

			oldSecret, newSecret := e.ObjectOld.(*corev1.Secret), e.ObjectNew.(*corev1.Secret)
			return !reflect.DeepEqual(oldSecret.Data, newSecret.Data)
		}
		return false
	},
	GenericFunc: func(e event.GenericEvent) bool {
		return isKubeConfigSecret(e.Object)
	},
}

Functions

func BuildRemoteCfg

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

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, kc api.Config) (*kubev1.Secret, error)

ToSecret converts a kubernetes api.Config to a secret with the provided name and 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)
}

func NewKubeLoader

func NewKubeLoader(timeout time.Duration) KubeLoader

default KubeLoader

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