add debug option to kubectl and helm

This commit is contained in:
hophacker 2020-02-21 14:32:34 +08:00
parent af089473bd
commit 6d6c453e8c

View File

@ -235,6 +235,7 @@ function gitcopy() {
} }
function kubectl() { function kubectl() {
CONTEXT=gcloud CONTEXT=gcloud
DEBUG=false
finalopts=() finalopts=()
while [[ $@ != "" ]] do while [[ $@ != "" ]] do
case $1 in case $1 in
@ -246,13 +247,17 @@ function kubectl() {
CONTEXT="${i#*=}" CONTEXT="${i#*=}"
shift shift
;; ;;
--debug)
DEBUG=true
shift
;;
*) *)
finalopts+=($1) finalopts+=($1)
shift shift
;; ;;
esac esac
done done
echo "kubectl $finalopts --kubeconfig=$HOME/.kube/${CONTEXT}_config" [[ $DEBUG == "true" ]] && echo "kubectl $finalopts --kubeconfig=$HOME/.kube/${CONTEXT}_config"
command kubectl $finalopts --kubeconfig=$HOME/.kube/${CONTEXT}_config command kubectl $finalopts --kubeconfig=$HOME/.kube/${CONTEXT}_config
} }
function stern { function stern {
@ -279,6 +284,7 @@ function stern {
} }
function helm() { function helm() {
CONTEXT=gcloud CONTEXT=gcloud
DEBUG=false
finalopts=() finalopts=()
while [[ $@ != "" ]] do while [[ $@ != "" ]] do
case $1 in case $1 in
@ -290,6 +296,11 @@ function helm() {
CONTEXT="${i#*=}" CONTEXT="${i#*=}"
shift shift
;; ;;
--debug)
DEBUG=true
finalopts+=($1)
shift
;;
*) *)
finalopts+=($1) finalopts+=($1)
shift shift
@ -301,7 +312,7 @@ function helm() {
gcloud) gcloud)
TLS="--tls" TLS="--tls"
esac esac
echo "helm $finalopts $TLS --kubeconfig=$HOME/.kube/${CONTEXT}_config" [[ $DEBUG == "true" ]] && echo "helm $finalopts $TLS --kubeconfig=$HOME/.kube/${CONTEXT}_config"
command helm $finalopts $TLS --kubeconfig=$HOME/.kube/${CONTEXT}_config command helm $finalopts $TLS --kubeconfig=$HOME/.kube/${CONTEXT}_config
} }
function kexec { function kexec {