MON-494 make path argument optional and normalize it
This commit is contained in:
parent
d8437ee676
commit
1eabd1f3f2
@ -9,7 +9,7 @@ auto_update:
|
||||
image: claranet/datadog-terraform:latest
|
||||
stage: test
|
||||
script:
|
||||
- ./scripts/auto_update.sh ./
|
||||
- ./scripts/auto_update.sh
|
||||
- git status
|
||||
- git diff --exit-code
|
||||
tags:
|
||||
|
||||
10
README.md
10
README.md
@ -10,13 +10,15 @@ To contribute you will need to [report an issue](https://confluence.fr.clara.net
|
||||
|
||||
If you would like to resolve an issue or implement new monitors you must follow our [best practices](https://confluence.fr.clara.net/display/DAT/Templates+monitors).
|
||||
|
||||
After any change on this repo, you need to run the `./scripts/auto_update.sh ./` command to make sure all is up to date otherwise the CI pipeline will fail:
|
||||
- the parameter will limit the scripts execution on a specific path on the repository
|
||||
After any change on this repo, you need to run the `./scripts/auto_update.sh [PATH_TO_MODULE]` command to make sure all is up to date otherwise the CI pipeline will fail:
|
||||
- the parameter is optional and it will limit the scripts execution on a specific path on the repository
|
||||
- on linux system it is possible to run the script directly while `terraform` and `terraform-docs` commands are available in your PATH
|
||||
- else you can use [the same docker image as the CI](https://hub.docker.com/r/claranet/datadog-terraform) with docker which is available on every platforms
|
||||
- else you can use [the same docker image as the CI](https://hub.docker.com/r/claranet/datadog-terraform) on every platforms
|
||||
|
||||
With this command run from the root of the repository you will get exactly the same execution as the pipeline (and so the same result also):
|
||||
|
||||
```
|
||||
docker run --rm -v "$PWD:/work" claranet/datadog-terraform /work/scripts/auto_update.sh ./
|
||||
docker run --rm -v "$PWD:/work" claranet/datadog-terraform /work/scripts/auto_update.sh
|
||||
```
|
||||
|
||||
## Important notes ##
|
||||
|
||||
@ -5,7 +5,7 @@ source "$(dirname $0)/utils.sh"
|
||||
goto_root
|
||||
|
||||
# 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
|
||||
|
||||
@ -36,7 +36,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
|
||||
|
||||
@ -6,8 +6,10 @@ goto_root
|
||||
|
||||
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))"
|
||||
|
||||
@ -5,7 +5,7 @@ source "$(dirname $0)/utils.sh"
|
||||
goto_root
|
||||
|
||||
# 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"
|
||||
|
||||
@ -6,7 +6,7 @@ goto_root
|
||||
|
||||
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" {
|
||||
|
||||
@ -9,5 +9,5 @@ source "$(dirname $0)/utils.sh"
|
||||
cd $(dirname $0)
|
||||
|
||||
for script in [0-9][0-9]_*.sh; do
|
||||
./${script} "$(get_scope $1)"
|
||||
./${script} "$(get_scope ${1-})"
|
||||
done
|
||||
|
||||
@ -10,10 +10,13 @@ function goto_root {
|
||||
}
|
||||
|
||||
function get_scope {
|
||||
TO_PARSE="."
|
||||
if [ ! -z ${1+x} ]; then
|
||||
TO_PARSE="./"
|
||||
if [ ! -z ${1+x} ] && [ $1 != "." ]; then
|
||||
TO_PARSE="$1"
|
||||
fi
|
||||
if [[ $TO_PARSE != ./* ]]; then
|
||||
TO_PARSE="./${TO_PARSE}"
|
||||
fi
|
||||
echo $TO_PARSE
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user