kubeconfig

package
v0.0.0-...-fe3d3e7 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package kubeconfig manages the user's kubeconfig. Its primary use is to merge a newly created kubeconfig into the default kubeconfig location and switching the in-use context to the newly merged one.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetKubeconfigContext

func GetKubeconfigContext(filepath string) (string, error)

GetKubeconfigContext returns the current context for a passed in kubeconfig file Returns an empty string if no context is set

Types

type KubeConfig

type KubeConfig struct {
	// contains filtered or unexported fields
}

KubeConfig contains information about the kubeconfig location.

func (*KubeConfig) MergeToDefaultConfig

func (kc *KubeConfig) MergeToDefaultConfig(kubeconfigPath string) error

MergeToDefaultConfig merges configuration to the kubeconfig file.

func (*KubeConfig) SetCurrentContext

func (kc *KubeConfig) SetCurrentContext(name string) error

SetCurrentContext sets the current kubeconfig context.

type Manager

type Manager interface {
	// MergeToDefaultConfig takes a kubeconfig file and merges it into the default kube config location.
	// It does not mutate existing cluster configs, unless there is a record with the same name. In this
	// case, the existing cluster details are overwritten.
	MergeToDefaultConfig(kubeconfigPath string) error
	// SetCurrentContext changes the kubeconfig context (`current-context` value) to the name passed in.
	SetCurrentContext(name string) error
}

Manager exposes operations that can be to a user's kubeconfig

func NewManager

func NewManager() Manager

NewManager returns a KubeConfigMgr implemented by KubeConfig. It automatically resolves the default config location for the user's machine and stores it locally for future context and merge operations.

Jump to

Keyboard shortcuts

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