util

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfigFilePath

func GetConfigFilePath() string

GetConfigFilePath if set KUBECONFING than return this or return RecomendedHomeFile (ex. /home/$USER/.kube/config)

func GetContexts

func GetContexts(config clientcmdapi.Config) []string

GetContexts return context names in kubeconfig struct

func GetCurrentContext added in v1.0.1

func GetCurrentContext() (string, string)

GetCurrentContext is return current-context and this context's namespace

func GetNamespaces

func GetNamespaces() []string

GetNamespaces is accessing current context and returning all namespace name

func GetRawConfig

func GetRawConfig() clientcmdapi.Config

GetRawConfig is return kubeconfig struct, if have a multiple kubeconfig before merged later return struct

func IsExistsPrevConfig added in v1.0.1

func IsExistsPrevConfig() (string, bool)

IsExistsPrevConfig checker Prevconfig exists and return bool,configPath

func SetContext

func SetContext(contex string)

SetContext Change current context in first file if setting KUBECONFIG env,because kubectl look first file in KUBECONFIG env ,if not set env than looking home config

func SetNamespace

func SetNamespace(config clientcmdapi.Config, namespace string)

SetNamespace is changed current namespace for current context, if have a multiple kubeconfig, searching context name in KUBECONFIG env later writing to founded ConfigPath

Types

type PrevConfig added in v1.0.1

type PrevConfig struct {
	PrevContext   string `yaml:"PrevContext"`
	PrevNamespace string `yaml:"PrevNamespace"`
}

PrevConfig Previous Context and Namespace storage type

func GetPrevConfig added in v1.0.1

func GetPrevConfig() PrevConfig

GetPrevConfig return PrevConfig struct, if PrevConfig not exists than create empty config

func (*PrevConfig) SetContextPrevConfig added in v1.0.1

func (config *PrevConfig) SetContextPrevConfig(context string)

SetContextPrevConfig is change prev context and empty namespace

func (*PrevConfig) SetNamespacePrevConfig added in v1.0.1

func (config *PrevConfig) SetNamespacePrevConfig(namespace string)

SetNamespacePrevConfig is changer prev namespace

func (*PrevConfig) WriteFile added in v1.0.1

func (config *PrevConfig) WriteFile()

WriteFile is save current PrevConfig struct to file

Jump to

Keyboard shortcuts

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