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
set -u
source "$(dirname $0)/utils.sh"
goto_root
init
function check_command() {
local cmd="$1"

View File

@ -1,11 +1,10 @@
#!/bin/bash
set -xueo pipefail
source "$(dirname $0)/utils.sh"
goto_root
init
# 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)
# empty outputs
> outputs.tf

View File

@ -1,12 +1,11 @@
#!/bin/bash
set -xueo pipefail
source "$(dirname $0)/utils.sh"
goto_root
init
# 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"
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)
@ -36,7 +35,7 @@ done
PATTERN_DOC="Related documentation"
# 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)
EXIST=0
if [ -f README.md ]; then
@ -94,7 +93,7 @@ EOF
# parse monitor's name
name=$(get_name "${match}")
# 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
if ! grep -A4 "${BASH_REMATCH[1]}" inputs.tf | grep default.*true; then
name="${name} (disabled by default)"
@ -123,6 +122,6 @@ EOF
rm README.md.bak
fi
# 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
done

View File

@ -1,15 +1,11 @@
#!/bin/bash
set -xueo pipefail
source "$(dirname $0)/utils.sh"
goto_root
init
root=$(basename ${PWD})
echo "$(get_scope ${1-})"
exit
# 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)
# get name of the monitors set directory
resource="$(basename $(dirname $path))"

View File

@ -1,11 +1,10 @@
#!/bin/bash
set -xueo pipefail
source "$(dirname $0)/utils.sh"
goto_root
init
# 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
if [[ $(grep -c notify_no_data.*true $path) -gt 1 ]]; then
echo "More than one notify_no_data set to true on $path"

View File

@ -1,12 +1,11 @@
#!/bin/bash
set -xueo pipefail
source "$(dirname $0)/utils.sh"
goto_root
init
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})
cat <<EOF > ${dir}/tmp.tf
provider "datadog" {

View File

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

View File

@ -1,6 +1,6 @@
#!/bin/bash
function goto_root {
function goto_root() {
script_dir=$(dirname $0)
if [[ "$script_dir" == "." ]]; then
cd ..
@ -9,7 +9,20 @@ function goto_root {
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="./"
if [ ! -z ${1+x} ] && [ $1 != "." ]; then
TO_PARSE="$1"
@ -20,11 +33,11 @@ function get_scope {
echo $TO_PARSE
}
function list_dirs {
function list_dirs() {
echo ${1} | awk -F '/' '{$1=""; print $0}' | cut -c 2-
}
function get_name {
function get_name() {
regex='^[[:space:]]+name[[:space:]]+=[[:space:]]+"\$.*\[.*\][[:space:]]+(.*)"$'
if [[ "${1}" =~ ${regex} ]]; then
name="${BASH_REMATCH[1]}"