MON-494 mode debug only for ci

This commit is contained in:
Quentin Manfroi 2019-08-07 19:04:34 +02:00
parent 1eabd1f3f2
commit e9ee3f2413
8 changed files with 33 additions and 34 deletions

View File

@ -1,8 +1,7 @@
#!/bin/bash #!/bin/bash
set -u
source "$(dirname $0)/utils.sh" source "$(dirname $0)/utils.sh"
goto_root init
function check_command() { function check_command() {
local cmd="$1" local cmd="$1"

View File

@ -1,11 +1,10 @@
#!/bin/bash #!/bin/bash
set -xueo pipefail
source "$(dirname $0)/utils.sh" source "$(dirname $0)/utils.sh"
goto_root init
# loop over every monitors set # loop over every monitors set
for path in $(find "$(get_scope ${1-})" -name 'monitors-*.tf' -print | sort -fdbi); do for path in $(find "$(get_scope ${1:-})" -name 'monitors-*.tf' -print | sort -fdbi); do
cd $(dirname $path) cd $(dirname $path)
# empty outputs # empty outputs
> outputs.tf > outputs.tf

View File

@ -1,12 +1,11 @@
#!/bin/bash #!/bin/bash
set -xueo pipefail
source "$(dirname $0)/utils.sh" source "$(dirname $0)/utils.sh"
goto_root 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 -Lo ${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 ## root README generator
# only keep current README from begining to "Monitors summary" section (delete monitors list) # only keep current README from begining to "Monitors summary" section (delete monitors list)
@ -36,7 +35,7 @@ done
PATTERN_DOC="Related documentation" PATTERN_DOC="Related documentation"
# loop over every monitors set readme # loop over every monitors set readme
for path in $(find "$(get_scope ${1-})" -name 'monitors-*.tf' -print | sort -fdbi); do for path in $(find "$(get_scope ${1:-})" -name 'monitors-*.tf' -print | sort -fdbi); do
cd $(dirname $path) cd $(dirname $path)
EXIST=0 EXIST=0
if [ -f README.md ]; then if [ -f README.md ]; then
@ -94,7 +93,7 @@ EOF
# parse monitor's name # parse monitor's name
name=$(get_name "${match}") name=$(get_name "${match}")
# search if monitor is enabled # search if monitor is enabled
[[ "$(grep -B1 "$name" $(basename ${path}) | grep enabled)" =~ ^[[:space:]]*count[[:space:]]*=[[:space:]]*var\.([a-z0-9_]*_enabled) ]] && [[ "$(grep -B1 "$name" $(basename ${path}) | grep -q enabled)" =~ ^[[:space:]]*count[[:space:]]*=[[:space:]]*var\.([a-z0-9_]*_enabled) ]] &&
# add "disabled by default" mention if not enabled # add "disabled by default" mention if not enabled
if ! grep -A4 "${BASH_REMATCH[1]}" inputs.tf | grep default.*true; then if ! grep -A4 "${BASH_REMATCH[1]}" inputs.tf | grep default.*true; then
name="${name} (disabled by default)" name="${name} (disabled by default)"
@ -123,6 +122,6 @@ EOF
rm README.md.bak rm README.md.bak
fi fi
# force unix format (I don't know why for now but you never know) # force unix format (I don't know why for now but you never know)
dos2unix README.md dos2unix README.md 2> /dev/null
cd - >> /dev/null cd - >> /dev/null
done done

View File

@ -1,15 +1,11 @@
#!/bin/bash #!/bin/bash
set -xueo pipefail
source "$(dirname $0)/utils.sh" source "$(dirname $0)/utils.sh"
goto_root init
root=$(basename ${PWD}) root=$(basename ${PWD})
echo "$(get_scope ${1-})"
exit
# loop over every monitors set # loop over every monitors set
for path in $(find "$(get_scope ${1-})" -name 'monitors-*.tf' -print | sort -fdbi); do for path in $(find "$(get_scope ${1:-})" -name 'monitors-*.tf' -print | sort -fdbi); do
cd $(dirname $path) cd $(dirname $path)
# get name of the monitors set directory # get name of the monitors set directory
resource="$(basename $(dirname $path))" resource="$(basename $(dirname $path))"

View File

@ -1,11 +1,10 @@
#!/bin/bash #!/bin/bash
set -xueo pipefail
source "$(dirname $0)/utils.sh" source "$(dirname $0)/utils.sh"
goto_root init
# loop over every monitors set # loop over every monitors set
for path in $(find "$(get_scope ${1-})" -name 'monitors-*.tf' -print | sort -fdbi); do for path in $(find "$(get_scope ${1:-})" -name 'monitors-*.tf' -print | sort -fdbi); do
# check if there is more than 1 notify_no_data parameter set to true per set of monitors # check if there is more than 1 notify_no_data parameter set to true per set of monitors
if [[ $(grep -c notify_no_data.*true $path) -gt 1 ]]; then if [[ $(grep -c notify_no_data.*true $path) -gt 1 ]]; then
echo "More than one notify_no_data set to true on $path" echo "More than one notify_no_data set to true on $path"

View File

@ -1,12 +1,11 @@
#!/bin/bash #!/bin/bash
set -xueo pipefail
source "$(dirname $0)/utils.sh" source "$(dirname $0)/utils.sh"
goto_root init
provider_version=$(grep ^[[:space:]]*version[[:space:]]= README.md | awk '{print $3}') provider_version=$(grep ^[[:space:]]*version[[:space:]]= README.md | awk '{print $3}')
for path in $(find "$(get_scope ${1-})" -name 'inputs.tf' -print); do for path in $(find "$(get_scope ${1:-})" -name 'inputs.tf' -print); do
dir=$(dirname ${path}) dir=$(dirname ${path})
cat <<EOF > ${dir}/tmp.tf cat <<EOF > ${dir}/tmp.tf
provider "datadog" { provider "datadog" {

View File

@ -1,13 +1,8 @@
#!/bin/bash #!/bin/bash
set -xueo pipefail
# MON-478 fix sort order behavior on case
export LC_COLLATE=C
source "$(dirname $0)/utils.sh" source "$(dirname $0)/utils.sh"
init scripts
cd $(dirname $0)
for script in [0-9][0-9]_*.sh; do for script in [0-9][0-9]_*.sh; do
./${script} "$(get_scope ${1-})" ./${script} "$(get_scope ${1:-})"
done done

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
function goto_root { function goto_root() {
script_dir=$(dirname $0) script_dir=$(dirname $0)
if [[ "$script_dir" == "." ]]; then if [[ "$script_dir" == "." ]]; then
cd .. cd ..
@ -9,7 +9,20 @@ function goto_root {
fi fi
} }
function get_scope { function init() {
set -euo pipefail
if [[ ${GITLAB_CI:-} == "true" ]]; then
set -x
fi
# MON-478 fix sort order behavior on case
export LC_COLLATE=C
goto_root
if ! [ -z ${1:-} ]; then
cd "$1"
fi
}
function get_scope() {
TO_PARSE="./" TO_PARSE="./"
if [ ! -z ${1+x} ] && [ $1 != "." ]; then if [ ! -z ${1+x} ] && [ $1 != "." ]; then
TO_PARSE="$1" TO_PARSE="$1"
@ -20,11 +33,11 @@ function get_scope {
echo $TO_PARSE echo $TO_PARSE
} }
function list_dirs { function list_dirs() {
echo ${1} | awk -F '/' '{$1=""; print $0}' | cut -c 2- echo ${1} | awk -F '/' '{$1=""; print $0}' | cut -c 2-
} }
function get_name { function get_name() {
regex='^[[:space:]]+name[[:space:]]+=[[:space:]]+"\$.*\[.*\][[:space:]]+(.*)"$' regex='^[[:space:]]+name[[:space:]]+=[[:space:]]+"\$.*\[.*\][[:space:]]+(.*)"$'
if [[ "${1}" =~ ${regex} ]]; then if [[ "${1}" =~ ${regex} ]]; then
name="${BASH_REMATCH[1]}" name="${BASH_REMATCH[1]}"