fix: Set the current ns if one is not set

This commit is contained in:
Nikolai Rodionov 2023-06-20 00:22:05 +02:00
parent dac88324a5
commit 011ee485aa
No known key found for this signature in database
GPG Key ID: 19DB54039EBF8F10
2 changed files with 3 additions and 1 deletions

View File

@ -27,3 +27,4 @@ Examples:
``` ```
$ kubers -n $SECRET_NAME $ kubers -n $SECRET_NAME
``` ```

View File

@ -20,6 +20,7 @@ funcion _kubers() {
_values compadd $(kubectl get namespaces --no-headers -o custom-columns=":metadata.name") _values compadd $(kubectl get namespaces --no-headers -o custom-columns=":metadata.name")
;; ;;
secret) secret)
NAMESPACE=$(kubectl config view --minify -o jsonpath='{..namespace}')
for (( i = 1; i <= $#words - 1; i++ )); do for (( i = 1; i <= $#words - 1; i++ )); do
if [[ $words[$i] == -n || $words[$i] == --namespace ]]; then if [[ $words[$i] == -n || $words[$i] == --namespace ]]; then
NAMESPACE=$words[$((i+1))] NAMESPACE=$words[$((i+1))]
@ -40,4 +41,4 @@ funcion _kubers() {
_values compadd $(for KEY in $(kubectl --namespace $NAMESPACE get secret $SECRET_NAME -o yaml | yq '.data | keys' | sed -e "s/- //"); do echo $KEY; done) _values compadd $(for KEY in $(kubectl --namespace $NAMESPACE get secret $SECRET_NAME -o yaml | yq '.data | keys' | sed -e "s/- //"); do echo $KEY; done)
;; ;;
esac esac
} }