From bd4bc1b7ee64b8146373441a048fc15b130b5b00 Mon Sep 17 00:00:00 2001 From: Gal Szkolnik Date: Tue, 2 Aug 2022 07:27:25 -0400 Subject: [PATCH] =Streamlined gcp/terraform helpers --- _home/dot_sz.shrc.d/11_direnv.env | 2 +- _home/dot_sz.shrc.d/32_gcp.shortcuts | 4 ++-- _home/dot_sz.shrc.d/33_terraform.shortcuts | 11 ++++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/_home/dot_sz.shrc.d/11_direnv.env b/_home/dot_sz.shrc.d/11_direnv.env index 4efdd01..a956fa5 100644 --- a/_home/dot_sz.shrc.d/11_direnv.env +++ b/_home/dot_sz.shrc.d/11_direnv.env @@ -3,7 +3,7 @@ if [[ -n "$(which-command direnv)" ]]; then if [[ -z "$_DIRENV_ShowEnvLogic" ]]; then echo "_DIRENV_ShowEnvLogic is not defined." if [[ $# -gt 0 ]]; then - local _DIRENV_ShowEnvLogic='printenv' + local _DIRENV_ShowEnvLogic='set' printf "Searching environment for: '${@}'\n\n" fi fi diff --git a/_home/dot_sz.shrc.d/32_gcp.shortcuts b/_home/dot_sz.shrc.d/32_gcp.shortcuts index 8d0e9c3..b75e72d 100644 --- a/_home/dot_sz.shrc.d/32_gcp.shortcuts +++ b/_home/dot_sz.shrc.d/32_gcp.shortcuts @@ -35,10 +35,10 @@ function gcp_get_stack() { local N="${1:-$(basename $PWD)}" local _cmd="{ $(printf "%s " \ "N='$N'; CLOUDSDK_ACTIVE_CONFIG_NAME=dust-personal; echo 'Listing $N stack:'; " \ - '{ gcloud compute instances list --filter="name:$N" | ' "sed s/^/Instances:\ /g ; } " \ - '&& { gcloud compute networks list --filter="name:$N" | ' "sed s/^/Networks.:\ /g ; } " \ + '{ gcloud compute networks list --filter="name:$N" | ' "sed s/^/Networks.:\ /g ; } " \ '&& { gcloud compute networks subnets list --filter="name:$N" | ' "sed s/^/Subnets..:\ /g ; } " \ '&& { gcloud compute disks list --filter="name:$N" | ' "sed s/^/Disks....:\ /g ; } " \ + '&& { gcloud compute instances list --filter="name:$N" | ' "sed s/^/Instances:\ /g ; } " \ ) ;}" [ $# -ge 2 ] && _cmd="watch -n${2} '$_cmd'" [[ -n ${SZ_DEBUG} ]] && printf "Executing: \n\t$_cmd\n\n" diff --git a/_home/dot_sz.shrc.d/33_terraform.shortcuts b/_home/dot_sz.shrc.d/33_terraform.shortcuts index 615cc07..a1b3f8f 100644 --- a/_home/dot_sz.shrc.d/33_terraform.shortcuts +++ b/_home/dot_sz.shrc.d/33_terraform.shortcuts @@ -10,18 +10,18 @@ if [[ -x $TERRAFORM_BIN ]]; then basename $PWD } - function _tfsedFullStop() { + function _tf_sedFullStop() { sed --unbuffered '/^===FULLSTOP===$/q' | sed --unbuffered '/^===FULLSTOP===$/d' } - function _tfless() { + function less-tf() { local _TF_LOG_FILE=${1-_logs/0_0_lastrun.log} [[ "$1" == "-" ]] && _TF_LOG_FILE='_logs/0_0_lastrun.log' - [[ -z "$SZ_DEBUG" ]] || echo "_tfless: ${@} | LESS_NO_WAIT = '${LESS_NO_WAIT}'" + [[ -z "$SZ_DEBUG" ]] || echo "lessts: ${@} | LESS_NO_WAIT = '${LESS_NO_WAIT}'" [[ "$1" == "-" ]] && { [[ -z "$SZ_DEBUG" ]] || echo "tailing..." trap : INT; - tail -f $_TF_LOG_FILE | _tfsedFullStop; + tail -f $_TF_LOG_FILE | _tf_sedFullStop; } \ || { [[ -z "${LESS_NO_WAIT}" ]] \ && { @@ -44,6 +44,7 @@ if [[ -x $TERRAFORM_BIN ]]; then } } + alias tf!=_tfSetLogTS function _tfSetLogTS() { export TF_LOG_TS=$(date -d "today" +"%Y%m%d%H%M%S") } @@ -65,7 +66,7 @@ if [[ -x $TERRAFORM_BIN ]]; then echo "===FULLSTOP===" >> _logs/0_0_lastrun.log } & - _tfless - + less-tf - } function tf-plan() {