MON-494 rework scripts organization and splitting
This commit is contained in:
parent
e9ee3f2413
commit
8f34a19d26
@ -23,7 +23,9 @@ function check_version() {
|
|||||||
if [[ "$1" == "terraform" ]]; then
|
if [[ "$1" == "terraform" ]]; then
|
||||||
tmp_dir=$(mktemp -d)
|
tmp_dir=$(mktemp -d)
|
||||||
cd ${tmp_dir}
|
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)
|
cur_ver=$(terraform version | head -n 1 | cut -d' ' -f2)
|
||||||
|
set -o pipefail
|
||||||
cur_ver=${cur_ver#"v"}
|
cur_ver=${cur_ver#"v"}
|
||||||
cd - > /dev/null
|
cd - > /dev/null
|
||||||
rm -fr ${tmp_dir}
|
rm -fr ${tmp_dir}
|
||||||
|
|||||||
27
scripts/20_update_global_readme.sh
Executable file
27
scripts/20_update_global_readme.sh
Executable 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
|
||||||
@ -6,31 +6,6 @@ init
|
|||||||
# download awk script to hack terraform-docs
|
# download awk script to hack terraform-docs
|
||||||
TERRAFORM_AWK="/tmp/terraform-docs.awk"
|
TERRAFORM_AWK="/tmp/terraform-docs.awk"
|
||||||
curl -Lso ${TERRAFORM_AWK} "https://raw.githubusercontent.com/cloudposse/build-harness/master/bin/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
|
# this is the pattern from where custom information is saved to be restored
|
||||||
PATTERN_DOC="Related documentation"
|
PATTERN_DOC="Related documentation"
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user