From 820144675bac68a9c2cdd6de89b117591189b2e7 Mon Sep 17 00:00:00 2001 From: containerscrew <131241415+containerscrew@users.noreply.github.com> Date: Tue, 2 Apr 2024 17:21:18 +0200 Subject: [PATCH] Fix custom binary tfsum (remove bashrc function) --- .bashrc | 18 ------------------ Containerfile | 1 + bin/tfsum | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 18 deletions(-) create mode 100755 bin/tfsum diff --git a/.bashrc b/.bashrc index 6bce241..60a460d 100644 --- a/.bashrc +++ b/.bashrc @@ -116,23 +116,5 @@ if ! shopt -oq posix; then fi fi -tfsum() { - if [ -z "$1" ]; then - echo "You should type 'tfsum terraform|terragrunt'" - exit 1 - fi - - echo -en "Starting tf summary... Please wait\n" - - if [ -n "$2" ] && [ "$2" == "-v" ]; then - "$1" plan -out plan.tfplan - else - "$1" plan -out plan.tfplan 1> /dev/null - fi - - "$1" show -json plan.tfplan | tftools summarize --show-tags - if [ -f "plan.tfplan" ]; then rm plan.tfplan; fi -} - # Custom prompt PS1="\[\033[38;5;92m\]\u\[\033[0m\]@\[\033[38;5;27m\]container-tools \[\033[0m\]\w \[\033[38;5;40m\]>\[\033[0m\]" \ No newline at end of file diff --git a/Containerfile b/Containerfile index 0807aab..6ddbc46 100644 --- a/Containerfile +++ b/Containerfile @@ -67,4 +67,5 @@ RUN curl --proto '=https' --tlsv1.2 -sSfL https://raw.githubusercontent.com/cont USER $USERNAME WORKDIR $USER_HOME COPY .bashrc .bashrc +COPY bin/* /usr/local/bin ENTRYPOINT ["/bin/bash"] \ No newline at end of file diff --git a/bin/tfsum b/bin/tfsum new file mode 100755 index 0000000..e193e27 --- /dev/null +++ b/bin/tfsum @@ -0,0 +1,17 @@ +#!/bin/bash + +if [ -z "$1" ]; then + echo "You should type 'tfsum terraform|terragrunt'" + exit 1 +fi + +echo -en "Starting tf summary... Please wait" + +if [ -n "$2" ] && [ "$2" == "-v" ]; then + "$1" plan -out plan.tfplan +else + "$1" plan -out plan.tfplan 1> /dev/null +fi + +"$1" show -json plan.tfplan | tftools summarize --show-tags +if [ -f "plan.tfplan" ]; then rm plan.tfplan; fi