make kubectx consistent with kubens wrt. KUBECTL environment variable (#274)

This commit is contained in:
Chris Stefano 2020-11-14 00:09:28 +00:00 committed by GitHub
parent 8241576f28
commit 9527e308e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

16
kubectx
View File

@ -192,13 +192,15 @@ unset_context() {
}
main() {
if hash kubectl 2>/dev/null; then
KUBECTL=kubectl
elif hash kubectl.exe 2>/dev/null; then
KUBECTL=kubectl.exe
else
echo >&2 "kubectl is not installed"
exit 1
if [[ -z "${KUBECTL:-}" ]]; then
if hash kubectl 2>/dev/null; then
KUBECTL=kubectl
elif hash kubectl.exe 2>/dev/null; then
KUBECTL=kubectl.exe
else
echo >&2 "kubectl is not installed"
exit 1
fi
fi
if [[ "$#" -eq 0 ]]; then