fix: handle kubectl context unset

This commit is contained in:
Travis Illig 2020-11-02 09:32:40 -08:00 committed by Jan De Dobbeleer
parent 0ba62540ab
commit 1339048fb4
2 changed files with 10 additions and 1 deletions

View file

@ -20,5 +20,5 @@ func (k *kubectl) enabled() bool {
return false
}
k.contextName, _ = k.env.runCommand("kubectl", "config", "current-context")
return true
return k.contextName != ""
}

View file

@ -40,3 +40,12 @@ func TestKubectlEnabled(t *testing.T) {
assert.True(t, kubectl.enabled())
assert.Equal(t, expected, kubectl.string())
}
func TestKubectlNoContext(t *testing.T) {
args := &kubectlArgs{
enabled: true,
contextName: "",
}
kubectl := bootStrapKubectlTest(args)
assert.False(t, kubectl.enabled())
}