Documentation ¶
Index ¶
- Constants
- type Kubeconfig
- func (k *Kubeconfig) GetBytes() ([]byte, error)
- func (k *Kubeconfig) GetContextNames() ([]string, error)
- func (k *Kubeconfig) GetCurrentContext() string
- func (k *Kubeconfig) GetGardenerClusterName() string
- func (k *Kubeconfig) GetGardenerClusterType() string
- func (k *Kubeconfig) GetGardenerLandscapeIdentity() string
- func (k *Kubeconfig) GetGardenerProject() string
- func (k *Kubeconfig) GetKubeswitchContext() string
- func (k *Kubeconfig) IsGardenerKubeconfig() bool
- func (k *Kubeconfig) ModifyContextName(old, new string) error
- func (k *Kubeconfig) ModifyCurrentContext(name string) error
- func (k *Kubeconfig) ModifyGardenerClusterName(name string) error
- func (k *Kubeconfig) ModifyGardenerClusterType(clusterType string) error
- func (k *Kubeconfig) ModifyGardenerLandscapeIdentity(gardenerLandscapeIdentity string) error
- func (k *Kubeconfig) ModifyGardenerProject(namespace string) error
- func (k *Kubeconfig) ModifyKubeswitchContext(context string) error
- func (k *Kubeconfig) NamespaceOfContext(contextName string) (string, error)
- func (k *Kubeconfig) RemoveContext(name string) error
- func (k *Kubeconfig) SetContext(currentContext, originalContextBeforeAlias string, prefix string) error
- func (k *Kubeconfig) SetGardenerStoreMetaInformation(landscapeIdentity, clusterType, project, name string) error
- func (k *Kubeconfig) SetKubeswitchContext(context string) error
- func (k *Kubeconfig) SetNamespace(ctxName string, ns string) error
- func (k *Kubeconfig) SetNamespaceForCurrentContext(namespace string) error
- func (k *Kubeconfig) WriteKubeconfigFile() (string, error)
Constants ¶
const (
// TemporaryKubeconfigDir is a constant for the directory where the switcher stores the temporary kubeconfig files
TemporaryKubeconfigDir = "$HOME/.kube/.switch_tmp"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Kubeconfig ¶
type Kubeconfig struct {
// contains filtered or unexported fields
}
func New ¶
func New(kubeconfigData []byte, path string, useTmpFile bool) (*Kubeconfig, error)
New creates a new Kubeconfig representation based on the given kubeconfig data the format is validated
func NewKubeconfig ¶
func NewKubeconfig(kubeconfigData []byte) (*Kubeconfig, error)
Create kubeconfig file in the temporary directory
func NewKubeconfigForPath ¶
func NewKubeconfigForPath(path string) (*Kubeconfig, error)
NewKubeconfigForPath creates a kubeconfig representation based on an existing kubeconfig given by the path argument This will overwrite the kubeconfig given by path when calling WriteKubeconfigFile()
func (*Kubeconfig) GetBytes ¶
func (k *Kubeconfig) GetBytes() ([]byte, error)
func (*Kubeconfig) GetContextNames ¶
func (k *Kubeconfig) GetContextNames() ([]string, error)
GetContextNames returns all context names in the kubeconfig
func (*Kubeconfig) GetCurrentContext ¶
func (k *Kubeconfig) GetCurrentContext() string
GetCurrentContext returns "current-context" value in given kubeconfig object Node, or returns "" if not found.
func (*Kubeconfig) GetGardenerClusterName ¶
func (k *Kubeconfig) GetGardenerClusterName() string
GetGardenerClusterName returns the "gardener-cluster-name" value in given kubeconfig object Node, or returns "" if not found.
func (*Kubeconfig) GetGardenerClusterType ¶
func (k *Kubeconfig) GetGardenerClusterType() string
GetGardenerClusterType returns the "gardener-cluster-type" value in given kubeconfig object Node, or returns "" if not found.
func (*Kubeconfig) GetGardenerLandscapeIdentity ¶
func (k *Kubeconfig) GetGardenerLandscapeIdentity() string
GetGardenerLandscapeIdentity returns the "gardener-landscape-identity" value in given kubeconfig object Node, or returns "" if not found.
func (*Kubeconfig) GetGardenerProject ¶
func (k *Kubeconfig) GetGardenerProject() string
GetGardenerProject returns the "gardener-project" value in given kubeconfig object Node, or returns "" if not found.
func (*Kubeconfig) GetKubeswitchContext ¶
func (k *Kubeconfig) GetKubeswitchContext() string
GetKubeswitchContext returns the "kubeswitch-context" value in given kubeconfig object Node, or returns "" if not found.
func (*Kubeconfig) IsGardenerKubeconfig ¶
func (k *Kubeconfig) IsGardenerKubeconfig() bool
IsGardenerKubeconfig returns if this kubeconfig is a kubeconfig created by a kubeswitch Gardener Store i.e needs to contain meta information added previously by the gardener store
func (*Kubeconfig) ModifyContextName ¶
func (k *Kubeconfig) ModifyContextName(old, new string) error
func (*Kubeconfig) ModifyCurrentContext ¶
func (k *Kubeconfig) ModifyCurrentContext(name string) error
func (*Kubeconfig) ModifyGardenerClusterName ¶
func (k *Kubeconfig) ModifyGardenerClusterName(name string) error
ModifyGardenerClusterName adds top-level fields with the following identifiers to the kubeconfig file. - "shoot-name" Only relevant for Gardener stores
func (*Kubeconfig) ModifyGardenerClusterType ¶
func (k *Kubeconfig) ModifyGardenerClusterType(clusterType string) error
ModifyGardenerClusterType adds top-level fields with the following identifiers to the kubeconfig file. - "gardener-cluster-type" (e.g "Shoot" or "Seed") Only relevant for Gardener stores
func (*Kubeconfig) ModifyGardenerLandscapeIdentity ¶
func (k *Kubeconfig) ModifyGardenerLandscapeIdentity(gardenerLandscapeIdentity string) error
ModifyGardenerLandscapeIdentity add a top-level field with the following identifiers to the kubeconfig file. - "landscape-identity" Only relevant for Gardener stores
func (*Kubeconfig) ModifyGardenerProject ¶
func (k *Kubeconfig) ModifyGardenerProject(namespace string) error
ModifyGardenerProject adds top-level fields with the following identifiers to the kubeconfig file. - "gardener-project" Only relevant for Gardener stores
func (*Kubeconfig) ModifyKubeswitchContext ¶
func (k *Kubeconfig) ModifyKubeswitchContext(context string) error
ModifyKubeswitchContext adds a top-level field with the key "kubeswitch-context" to the kubeconfig file. This context is the kubeswitch prefix (store dependent) / <kubeconfig-context> this is done when creating a new temporary copy of the kubeconfig file when "switching" to it During change of namespaces the current context information
func (*Kubeconfig) NamespaceOfContext ¶
func (k *Kubeconfig) NamespaceOfContext(contextName string) (string, error)
func (*Kubeconfig) RemoveContext ¶
func (k *Kubeconfig) RemoveContext(name string) error
func (*Kubeconfig) SetContext ¶
func (k *Kubeconfig) SetContext(currentContext, originalContextBeforeAlias string, prefix string) error
SetContext sets the given context as a current context on the kubeconfig if the given context is an alias, then it also modifies the kubeconfig so that both the current-context as well as the contexts.context name are set to the alias (otherwise the current-context would point to a non-existing context name)
func (*Kubeconfig) SetGardenerStoreMetaInformation ¶
func (k *Kubeconfig) SetGardenerStoreMetaInformation(landscapeIdentity, clusterType, project, name string) error
SetGardenerStoreMetaInformation is a function to add meta information to kubeconfig which is required for subsequent runs of kubeswitch Only relevant to the Gardener store
func (*Kubeconfig) SetKubeswitchContext ¶
func (k *Kubeconfig) SetKubeswitchContext(context string) error
func (*Kubeconfig) SetNamespace ¶
func (k *Kubeconfig) SetNamespace(ctxName string, ns string) error
func (*Kubeconfig) SetNamespaceForCurrentContext ¶
func (k *Kubeconfig) SetNamespaceForCurrentContext(namespace string) error
func (*Kubeconfig) WriteKubeconfigFile ¶
func (k *Kubeconfig) WriteKubeconfigFile() (string, error)
WriteKubeconfigFile writes kubeconfig bytes to the local filesystem and returns the kubeconfig path