Skip to content

Commit

Permalink
Add diff friendly plan
Browse files Browse the repository at this point in the history
  • Loading branch information
Mongey committed Apr 19, 2022
1 parent 4c113ff commit 7ee32df
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion terraform-v2/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 <plan.txt; then
if ! python3 /tmp/github.py plan <diff_friendly_plan.txt; then
echo "Error adding comment to PR"
fi
fi
2 changes: 2 additions & 0 deletions terraform/comment_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
'<summary>View Terraform Plan</summary>\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'
'</details>\n'
Expand Down

0 comments on commit 7ee32df

Please sign in to comment.