From 630ebb3299dc1407a21046786489cd4fce50eeda Mon Sep 17 00:00:00 2001 From: Olivier Grand Date: Mon, 20 Feb 2023 12:01:13 +0100 Subject: [PATCH] fix log-k8s, add completion for tfctl and refine credhub-get alias with version selection --- bosh-cli/bash_aliases | 2 +- bosh-cli/bash_profile | 5 ++++- bosh-cli/log-k8s.sh | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/bosh-cli/bash_aliases b/bosh-cli/bash_aliases index 14d2429..aeed9f2 100644 --- a/bosh-cli/bash_aliases +++ b/bosh-cli/bash_aliases @@ -12,7 +12,7 @@ alias bosh-depls-failed="bosh is --json | jq -r '.Tables[].Rows[]|select(.proces alias bosh-events="bosh events | grep \"hm \" | grep -E \"create|delete\"" alias bosh-task='function __bt() { bosh task $1 --debug | grep -vE " BEGIN| COMMIT| SELECT |INSERT INTO|DELETE FROM| UPDATE | WHERE |Renewing lock"; }; __bt' alias clean-prometheus-tasks='for var in $(bosh tasks | grep "prometheus" | grep -E "queued|processing" | sed -e "s+\t.*++g") ; do bosh cancel-task $var ; done' -alias credhub-get='function __cg() { log-credhub -i ; credhub get -n $1 -j | jq .value -r; }; __cg' +alias credhub-get='function __cg() { index=$2 ; log-credhub -i ; credhub get -n $1 --versions=$(($index + 1)) -j | jq -r .versions[$index].value; }; __cg' alias fly='fly -t concourse' alias hm-bosh-tasks="bosh tasks -a -r=20000 --json | jq -r '.Tables[].Rows[]|select(.user == \"hm\")|.started_at + \" \" + .id + \" \" + .description + \" \" + .deployment + \" => \" + .result'" alias k='/usr/local/bin/kubectl' diff --git a/bosh-cli/bash_profile b/bosh-cli/bash_profile index 15f7fa5..f899899 100644 --- a/bosh-cli/bash_profile +++ b/bosh-cli/bash_profile @@ -100,7 +100,10 @@ echo -en "\033]0;${MY_BOSH_USER}@${SITE_NAME}\007" export GREP_COLORS="fn=1;34:se=1;34:mt=1;33" #--- bosh cli completion -eval "$(/home/bosh/bosh-complete-linux bash-source)" +source <(/home/bosh/bosh-complete-linux bash-source) + +#--- tfctl cli completion +source <(tfctl completion bash) #--- kubectl plugin completion source <(kubectl get-all completion bash | sed -e "s+ get-all$+ kubectl-get_all+g") diff --git a/bosh-cli/log-k8s.sh b/bosh-cli/log-k8s.sh index b88cf08..f6b7e36 100755 --- a/bosh-cli/log-k8s.sh +++ b/bosh-cli/log-k8s.sh @@ -165,6 +165,7 @@ if [ ${flagError} = 0 ] ; then fi fi + export KUBECONFIG="${HOME}/.kube/config" if [ ${flagError} = 0 ] ; then #--- Connect to cluster if [ "${K8S_TYPE_CLUSTER}" = "openshift" ] ; then @@ -197,8 +198,7 @@ if [ ${flagError} = 0 ] ; then fi if [ ${flagError} = 0 ] ; then - printf "\n\n%bCluster \"${K8S_CONTEXT}\" available.%b\n" "${YELLOW}${REVERSE}" "${STD}" - export KUBECONFIG="${HOME}/.kube/config" + printf "\n%bCluster \"${K8S_CONTEXT}\" available.%b\n" "${YELLOW}${REVERSE}" "${STD}" fi fi fi \ No newline at end of file