Commit 0baa04e5 authored by nimrod's avatar nimrod
Browse files

Validate Terraform according to workspace.

Use the variable file matching the workspace when validating. Also when
validating and formatting, show the diff.
parent e9d6826b
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ alias listen_tcp='nc -vlk 0.0.0.0'
alias listen_udp='nc -uvlk 0.0.0.0'
alias listen_unix='nc -Uvlk'
alias tfa='terraform apply tfplan'
alias tfvf='terraform validate && terraform fmt'
alias tfvf='tfv && terraform fmt -diff'

if ! command -v notify-send > /dev/null
then
@@ -174,6 +174,16 @@ tfi () {
    fi
}

tfv () {
    workspace="$(terraform workspace show)"
    if [ "$workspace" = "default" ] || [ ! -f "$workspace.tfvars" ]
    then
        terraform validate "$@"
    else
        terraform validate -var-file "$workspace.tfvars" "$@"
    fi
}

genpass () {
    bytes="${1:-32}"
    head --bytes="$bytes" /dev/urandom | base64 --wrap=0