mirror of
https://github.com/ahmetb/kubectx.git
synced 2025-09-13 22:38:59 +00:00
Move kubeconfig utility to a shared pkg
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
17
internal/kubeconfig/currentcontext.go
Normal file
17
internal/kubeconfig/currentcontext.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package kubeconfig
|
||||
|
||||
// GetCurrentContext returns "current-context" value in given
|
||||
// kubeconfig object Node, or returns "" if not found.
|
||||
func (k *Kubeconfig) GetCurrentContext() string {
|
||||
v := valueOf(k.rootNode, "current-context")
|
||||
if v == nil {
|
||||
return ""
|
||||
}
|
||||
return v.Value
|
||||
}
|
||||
|
||||
func (k *Kubeconfig) UnsetCurrentContext() error {
|
||||
curCtxValNode := valueOf(k.rootNode, "current-context")
|
||||
curCtxValNode.Value = ""
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user