From c574e07f879b3b051f8fe3e41e9e9e54b9e0748d Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Thu, 27 Jun 2019 16:24:08 +0200 Subject: [PATCH] MON-459 update readme script to works with terraform 0.12 --- scripts/02_update_readme.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/02_update_readme.sh b/scripts/02_update_readme.sh index eba210e..ba44bd4 100755 --- a/scripts/02_update_readme.sh +++ b/scripts/02_update_readme.sh @@ -4,6 +4,10 @@ set -xueo pipefail source "$(dirname $0)/utils.sh" goto_root +# download awk script to hack terraform-docs +TERRAFORM_AWK="/tmp/terraform-docs.awk" +curl -Lo ${TERRAFORM_AWK} "https://raw.githubusercontent.com/cloudposse/build-harness/master/bin/terraform-docs.awk" + ## root README generator # only keep current README from begining to "Monitors summary" section (delete monitors list) sed -i '/### Monitors summary ###/q' README.md @@ -91,8 +95,12 @@ EOF done IFS=$SAVEIFS echo >> README.md + # hack for terraform-docs with terraform 0.12 / HCL2 support + tmp_tf=$(mktemp -d) + awk -f ${TERRAFORM_AWK} ./*.tf > ${tmp_tf}/main.tf # auto generate terraform docs (inputs and outputs) - terraform-docs --with-aggregate-type-defaults md table ./ >> README.md + terraform-docs --with-aggregate-type-defaults md table ${tmp_tf}/ >> README.md + rm -fr ${tmp_tf} # if README does not exist if [[ $EXIST -eq 0 ]]; then # Simply add empty documentation section