=Streamlined gcp/terraform helpers
This commit is contained in:
parent
b18c977d75
commit
bd4bc1b7ee
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue