From 7ee32df171b7c1d8d5f0c73e90b9b402f8dbc906 Mon Sep 17 00:00:00 2001 From: Conor Mongey Date: Tue, 19 Apr 2022 16:29:23 +0100 Subject: [PATCH] Add diff friendly plan --- terraform-v2/plan.sh | 4 +++- terraform/comment_util.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/terraform-v2/plan.sh b/terraform-v2/plan.sh index 8adbc86d..d3742f26 100644 --- a/terraform-v2/plan.sh +++ b/terraform-v2/plan.sh @@ -19,6 +19,8 @@ terraform -chdir=${module_path} plan -input=false -no-color -detailed-exitcode - | $COMPACT_PLAN \ >plan.txt +cat plan.txt | sed -E 's/^([[:space:]]+)([-+])/\2\1/g' > diff_friendly_plan.txt + readonly TF_EXIT=${PIPESTATUS[0]} set -e @@ -31,7 +33,7 @@ if [[ -n "$GITHUB_TOKEN" && "<< parameters.add_github_comment >>" == "true" ]]; export CIRCLE_PR_NUMBER="${CIRCLE_PR_NUMBER:-${CIRCLE_PULL_REQUEST##*/}}" export label="<< parameters.label >>" - if ! python3 /tmp/github.py plan View Terraform Plan\n\n' '```terraform\n' 'Output is limited to 1000 lines and may be truncated. See CircleCI for full details.\n' + '```\n' + '```diff\n' '{plan}\n' '```\n' '\n'