go-libs : kubeconfig
This package allow you to manipulate a Kubeconfig and interact with it.
Kubeconfig object
Kubeconfig object describe content and acces to the kubeconfig content.
| Property | Kind | Description |
|---|---|---|
| Config | string |
The content of the kubeconfig |
| Path | string |
The path to the kubeconfig file |
| display | *sxUtils.CmdDisplay |
Display context used for debug purposes |
Constructor
NewKubeConfig create a new Kubeconfig ready to use with a clientset prepared to interact with the kubernetes cluster.
Kubeconfig := NewKubeConfig()
Kubeconfig.LoadFromHome()
Kubeconfig.Debug()
Return an *Kubeconfig object.
Kubeconfig methods
Kubeconfig object propose a full set of methods.
| Method | Signature | Return | Description |
|---|---|---|---|
Debug |
none | *Kubeconfig |
Display in debug mode the content of the kubeconfig |
LoadFromFile |
filePath string |
*Kubeconfig, error |
Load kubeconfig from a file path |
LoadFromEnv |
fatal bool |
*Kubeconfig, error |
Load kubeconfig from the KUBECONFIG env var |
LoadFromHome |
none | *Kubeconfig, error |
Load kubeconfig from ~/.kube/config |
LoadFromYaml |
yamlData []byte |
*Kubeconfig |
Load kubeconfig from raw YAML bytes |
LoadFromString |
yamlString string |
*Kubeconfig |
Load kubeconfig from a YAML string |
Load |
exit bool |
error |
Auto-load: tries env, then home kubeconfig |
Save |
exit bool |
error |
Write Config to Path (falls back to ~/.kube/config) |
Get |
none | string |
Return the kubeconfig content (alias of GetConfig) |
GetConfig |
none | string |
Return the kubeconfig content |
GetConfigString |
none | string |
Return the kubeconfig content as string |
GetConfigBytes |
none | []byte, error |
Return the kubeconfig content as bytes (direct cast, no marshalling) |
GetYaml |
none | string |
Return the kubeconfig content as YAML string |
GetPath |
none | string |
Return the kubeconfig file path |