kubeconfigutils

package
v0.414.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetContextNameByClusterName added in v0.341.0

func GetContextNameByClusterName(ctx context.Context, clusterName string) (string, error)

func GetCurrentContext added in v0.414.0

func GetCurrentContext(ctx context.Context) (string, error)

func GetDefaultKubeConfigPath added in v0.341.0

func GetDefaultKubeConfigPath(ctx context.Context) (string, error)

func GetKubeConfigPath added in v0.341.0

func GetKubeConfigPath(ctx context.Context) (string, error)

func GetUserNameByContextName added in v0.341.0

func GetUserNameByContextName(ctx context.Context, userName string) (string, error)

func IsFilePathLoadableByKubectl

func IsFilePathLoadableByKubectl(ctx context.Context, path string) (isLoadable bool, err error)

This function does an exec to "kubectl" using the given config file "path". Useful to validate if a written config "path" is understood by "kubectl".

func ListContextNamesUsingKubectl

func ListContextNamesUsingKubectl(ctx context.Context, path string) (contextNames []string, err error)

Use exec to invoke a "kubectl config get-context" with the given config "path". Useful to validate if the config is understood correctly by kubectl.

func SetCurrentContext added in v0.414.0

func SetCurrentContext(ctx context.Context, contextToUse string) error

Types

type KubeConfig

type KubeConfig struct {
	APIVersion     string              `yaml:"apiVersion"`
	Kind           string              `yaml:"kind"`
	Clusters       []KubeConfigCluster `yaml:"clusters"`
	Contexts       []KubeConfigContext `yaml:"contexts"`
	CurrentContext string              `yaml:"current-context"`
	Users          []KubeConfigUser    `yaml:"users"`
}

func LoadFromFile

func LoadFromFile(ctx context.Context, file filesinterfaces.File) (config *KubeConfig, err error)

func LoadFromFilePath

func LoadFromFilePath(ctx context.Context, path string) (config *KubeConfig, err error)

func LoadKubeConfig added in v0.341.0

func LoadKubeConfig(ctx context.Context) (*KubeConfig, error)

func MergeConfig

func MergeConfig(configs ...*KubeConfig) (merged *KubeConfig, err error)

func (*KubeConfig) AddClusterAndContextAndUserEntry

func (k *KubeConfig) AddClusterAndContextAndUserEntry(cluster *KubeConfigCluster, kubeConfigContext *KubeConfigContext, user *KubeConfigUser) (err error)

func (*KubeConfig) AddClusterEntry

func (k *KubeConfig) AddClusterEntry(cluster *KubeConfigCluster) (err error)

func (*KubeConfig) AddConfig

func (k *KubeConfig) AddConfig(toAdd *KubeConfig) (err error)

func (*KubeConfig) AddContextEntry

func (k *KubeConfig) AddContextEntry(kubeConfigContext *KubeConfigContext) (err error)

func (*KubeConfig) AddUserEntry

func (k *KubeConfig) AddUserEntry(user *KubeConfigUser) (err error)

func (*KubeConfig) GetAsYamlString

func (k *KubeConfig) GetAsYamlString() (yamlSring string, err error)

func (*KubeConfig) GetClientKeyDataForUser added in v0.328.0

func (k *KubeConfig) GetClientKeyDataForUser(name string) (string, error)

func (*KubeConfig) GetClusterAndContextAndUserEntryByName

func (k *KubeConfig) GetClusterAndContextAndUserEntryByName(name string) (cluster *KubeConfigCluster, kubeConfigContext *KubeConfigContext, user *KubeConfigUser, err error)

func (*KubeConfig) GetClusterEntryByName

func (k *KubeConfig) GetClusterEntryByName(name string) (cluster *KubeConfigCluster, err error)

func (*KubeConfig) GetClusterNames

func (k *KubeConfig) GetClusterNames() (clusterNames []string, err error)

func (*KubeConfig) GetClusterServerUrlAsString added in v0.328.0

func (k *KubeConfig) GetClusterServerUrlAsString(clusterName string) (string, error)

func (*KubeConfig) GetContextEntryByName

func (k *KubeConfig) GetContextEntryByName(name string) (kubeConfigContext *KubeConfigContext, err error)

func (*KubeConfig) GetContextNameByClusterName added in v0.341.0

func (k *KubeConfig) GetContextNameByClusterName(ctx context.Context, clusterName string) (string, error)

func (*KubeConfig) GetCurrentContext added in v0.414.0

func (k *KubeConfig) GetCurrentContext(ctx context.Context) (string, error)

func (*KubeConfig) GetDeepCopy

func (k *KubeConfig) GetDeepCopy() (copy *KubeConfig)

func (*KubeConfig) GetServerNames

func (k *KubeConfig) GetServerNames() (serverNames []string, err error)

func (*KubeConfig) GetUserEntryByName

func (k *KubeConfig) GetUserEntryByName(name string) (kubeConfigContext *KubeConfigUser, err error)

func (*KubeConfig) GetUserNameByContextName

func (k *KubeConfig) GetUserNameByContextName(ctx context.Context, contextName string) (userName string, err error)

func (*KubeConfig) ListContextNames added in v0.414.0

func (k *KubeConfig) ListContextNames(ctx context.Context) ([]string, error)

func (*KubeConfig) SetCurrentContext added in v0.414.0

func (k *KubeConfig) SetCurrentContext(ctx context.Context, contextToUse string) error

func (*KubeConfig) WriteToFile

func (k *KubeConfig) WriteToFile(ctx context.Context, outFile filesinterfaces.File) (err error)

func (*KubeConfig) WriteToFileByPath

func (k *KubeConfig) WriteToFileByPath(ctx context.Context, path string) (err error)

func (*KubeConfig) WriteToTemporaryFileAndGetPath

func (k *KubeConfig) WriteToTemporaryFileAndGetPath(ctx context.Context) (tempFilePath string, err error)

type KubeConfigCluster

type KubeConfigCluster struct {
	Name    string                   `yaml:"name"`
	Cluster KubeConfigClusterCluster `yaml:"cluster"`
}

func (*KubeConfigCluster) GetServerUrlAsString added in v0.328.0

func (k *KubeConfigCluster) GetServerUrlAsString() (string, error)

type KubeConfigClusterCluster

type KubeConfigClusterCluster struct {
	Server                   string `yaml:"server"`
	CertificateAuthorityData string `yaml:"certificate-authority-data"`
}

type KubeConfigContext

type KubeConfigContext struct {
	Name    string `yaml:"name"`
	Context struct {
		Cluster   string `yaml:"cluster"`
		Namespace string `yaml:"namespace"`
		User      string `yaml:"user"`
	} `yaml:"context"`
}

func (KubeConfigContext) GetUserName

func (k KubeConfigContext) GetUserName() (userName string, err error)

type KubeConfigUser

type KubeConfigUser struct {
	Name string `yaml:"name"`
	User struct {
		ClientCertificateData string `yaml:"client-certificate-data"`
		ClientKeyData         string `yaml:"client-key-data"`
		Username              string `yaml:"username"`
		Password              string `yaml:"password"`
	} `yaml:"user"`
}

func (*KubeConfigUser) GetClientKeyData added in v0.328.0

func (k *KubeConfigUser) GetClientKeyData() (string, error)

Jump to

Keyboard shortcuts

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