MON-494 rework scripts organization and splitting

This commit is contained in:
Quentin Manfroi 2019-08-12 20:46:23 +02:00
parent e9ee3f2413
commit 8f34a19d26
5 changed files with 29 additions and 25 deletions

View File

@ -23,7 +23,9 @@ function check_version() {
if [[ "$1" == "terraform" ]]; then
tmp_dir=$(mktemp -d)
cd ${tmp_dir}
set +o pipefail # terraform fails on command piping when not last version
cur_ver=$(terraform version | head -n 1 | cut -d' ' -f2)
set -o pipefail
cur_ver=${cur_ver#"v"}
cd - > /dev/null
rm -fr ${tmp_dir}

View File

@ -0,0 +1,27 @@
#!/bin/bash
source "$(dirname $0)/utils.sh"
init
# only keep current README from begining to "Monitors summary" section (delete monitors list)
sed -i '/### Monitors summary ###/q' README.md
# add a newline after listing section
echo >> README.md
# loop over all ready monitors sets on the repo
for path in $(find -mindepth 1 -type d ! -path '*/.*' ! -path './scripts*' -print | sort -fdbi); do
# split path in directories
directories=($(list_dirs $path))
# loop over directories in path
for i in $(seq 1 $((${#directories[@]}-1))); do
## add tabulation for every subdirectory
echo -en "\t" >> README.md
done
# add link to list of monitors sets
echo -en "- [$(basename ${path})](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/" >> README.md
# add path to link
for directory in "${directories[@]}"; do
echo -en "${directory}/" >> README.md
done
# end of markdown link
echo ")" >> README.md
done

View File

@ -6,31 +6,6 @@ init
# download awk script to hack terraform-docs
TERRAFORM_AWK="/tmp/terraform-docs.awk"
curl -Lso ${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
# add a newline after listing section
echo >> README.md
# loop over all ready monitors sets on the repo
for path in $(find -mindepth 1 -type d ! -path '*/.*' ! -path './scripts*' -print | sort -fdbi); do
# split path in directories
directories=($(list_dirs $path))
# loop over directories in path
for i in $(seq 1 $((${#directories[@]}-1))); do
## add tabulation for every subdirectory
echo -en "\t" >> README.md
done
# add link to list of monitors sets
echo -en "- [$(basename ${path})](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/" >> README.md
# add path to link
for directory in "${directories[@]}"; do
echo -en "${directory}/" >> README.md
done
# end of markdown link
echo ")" >> README.md
done
# this is the pattern from where custom information is saved to be restored
PATTERN_DOC="Related documentation"