Improved gcp_get_stack code: leaner/cleaner output

This commit is contained in:
Gal Szkolnik 2022-07-25 15:03:24 -04:00
parent 9f1181ae02
commit d34c3b15d6
1 changed files with 10 additions and 7 deletions

View File

@ -32,14 +32,17 @@ function gcp_get_region_quotas() {
} }
function gcp_get_stack() { function gcp_get_stack() {
local _cmd=$(printf 'N="%s"; CLOUDSDK_ACTIVE_CONFIG_NAME=dust-personal; echo $N; ' $1) local N="${1:-$(basename $PWD)}"
_cmd+='{ echo "Instances"; gcloud compute instances list --filter="name:$N"; } ' local _cmd="{ $(printf "%s " \
_cmd+='&& { echo "Networks"; gcloud compute networks list --filter="name:$N"; } ' "N='$N'; CLOUDSDK_ACTIVE_CONFIG_NAME=dust-personal; echo 'Listing $N stack:'; " \
_cmd+='&& {gcloud compute networks subnets list --filter="name:$N"} ' '{ gcloud compute instances list --filter="name:$N" | ' "sed s/^/Instances:\ /g ; } " \
_cmd+='&& {gcloud compute disks list --filter="name:$N"}' '&& { gcloud compute networks list --filter="name:$N" | ' "sed s/^/Networks.:\ /g ; } " \
_cmd='{ }' '&& { gcloud compute networks subnets list --filter="name:$N" | ' "sed s/^/Subnets..:\ /g ; } " \
'&& { gcloud compute disks list --filter="name:$N" | ' "sed s/^/Disks....:\ /g ; } " \
) ;}"
[ $# -ge 2 ] && _cmd="watch -n${2} '$_cmd'" [ $# -ge 2 ] && _cmd="watch -n${2} '$_cmd'"
echo $_cmd [[ -n ${SZ_DEBUG} ]] && printf "Executing: \n\t$_cmd\n\n"
eval $_cmd
} }
# printf '\n\n'; gcp_get_stack 'dragonheart' 5 # printf '\n\n'; gcp_get_stack 'dragonheart' 5