mirror of
https://github.com/ahmetb/kubectx.git
synced 2025-08-08 10:47:31 +00:00
fix bats tests
This commit is contained in:
parent
30ad213b37
commit
608b90a332
@ -33,7 +33,11 @@ func (k *Kubeconfig) contextsNode() (*yaml.RNode, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (k *Kubeconfig) contextNode(name string) (*yaml.RNode, error) {
|
func (k *Kubeconfig) contextNode(name string) (*yaml.RNode, error) {
|
||||||
context, err := k.config.Pipe(yaml.Lookup("contexts", "[name="+name+"]"))
|
contexts, err := k.contextsNode()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
context, err := contexts.Pipe(yaml.Lookup("[name=" + name + "]"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
package kubeconfig
|
package kubeconfig
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
"sigs.k8s.io/kustomize/kyaml/yaml"
|
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -27,11 +25,7 @@ func (k *Kubeconfig) GetCurrentContext() string {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
str, err := v.String()
|
return yaml.GetValue(v)
|
||||||
if err != nil {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
return strings.TrimSpace(str)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *Kubeconfig) UnsetCurrentContext() error {
|
func (k *Kubeconfig) UnsetCurrentContext() error {
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
package kubeconfig
|
package kubeconfig
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
"sigs.k8s.io/kustomize/kyaml/yaml"
|
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -33,11 +31,7 @@ func (k *Kubeconfig) NamespaceOfContext(contextName string) (string, error) {
|
|||||||
if namespace == nil || err != nil {
|
if namespace == nil || err != nil {
|
||||||
return defaultNamespace, err
|
return defaultNamespace, err
|
||||||
}
|
}
|
||||||
nsStr, err := namespace.String()
|
return yaml.GetValue(namespace), nil
|
||||||
if nsStr == "" || err != nil {
|
|
||||||
return defaultNamespace, err
|
|
||||||
}
|
|
||||||
return strings.TrimSpace(nsStr), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *Kubeconfig) SetNamespace(ctxName string, ns string) error {
|
func (k *Kubeconfig) SetNamespace(ctxName string, ns string) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user