MON-259: Improve auto_update scripts
and allow to have an argument to target a specific directory when launched manually
This commit is contained in:
parent
cf688d9698
commit
a9bedaeedb
@ -4,7 +4,12 @@ set -xueo pipefail
|
|||||||
source "$(dirname $0)/utils.sh"
|
source "$(dirname $0)/utils.sh"
|
||||||
goto_root
|
goto_root
|
||||||
|
|
||||||
for path in $(find . -path ./incubator -prune -o -name 'monitors-*.tf' -print); do
|
TO_PARSE="."
|
||||||
|
if [ ! -z ${1+x} ]; then
|
||||||
|
TO_PARSE="$1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
for path in $(find $TO_PARSE -path ./incubator -prune -o -name 'monitors-*.tf' -print); do
|
||||||
cd $(dirname $path)
|
cd $(dirname $path)
|
||||||
> outputs.tf
|
> outputs.tf
|
||||||
for monitor in $(grep 'resource "datadog_monitor"' $(basename $path) | awk '{print $3}' | tr -d '"' ); do
|
for monitor in $(grep 'resource "datadog_monitor"' $(basename $path) | awk '{print $3}' | tr -d '"' ); do
|
||||||
@ -19,4 +24,4 @@ EOF
|
|||||||
done
|
done
|
||||||
cd - >> /dev/null
|
cd - >> /dev/null
|
||||||
done
|
done
|
||||||
terraform fmt
|
terraform fmt $TO_PARSE
|
||||||
|
|||||||
@ -4,6 +4,11 @@ set -xueo pipefail
|
|||||||
source "$(dirname $0)/utils.sh"
|
source "$(dirname $0)/utils.sh"
|
||||||
goto_root
|
goto_root
|
||||||
|
|
||||||
|
TO_PARSE="."
|
||||||
|
if [ ! -z ${1+x} ]; then
|
||||||
|
TO_PARSE="$1"
|
||||||
|
fi
|
||||||
|
|
||||||
sed -i '/### Monitors summary ###/q' README.md
|
sed -i '/### Monitors summary ###/q' README.md
|
||||||
echo >> README.md
|
echo >> README.md
|
||||||
for path in $(find -mindepth 1 \( -path './incubator' -o -path './scripts' -o -path './testing' -o -path '*/\.*' \) -prune -o -type d -print | sort); do
|
for path in $(find -mindepth 1 \( -path './incubator' -o -path './scripts' -o -path './testing' -o -path '*/\.*' \) -prune -o -type d -print | sort); do
|
||||||
@ -20,7 +25,7 @@ done
|
|||||||
|
|
||||||
PATTERN_DOC="Related documentation"
|
PATTERN_DOC="Related documentation"
|
||||||
|
|
||||||
for path in $(find . -path ./incubator -prune -o -name 'monitors-*.tf' -print); do
|
for path in $(find $TO_PARSE -path ./incubator -prune -o -name 'monitors-*.tf' -print); do
|
||||||
cd $(dirname $path)
|
cd $(dirname $path)
|
||||||
EXIST=0
|
EXIST=0
|
||||||
if [ -f README.md ]; then
|
if [ -f README.md ]; then
|
||||||
|
|||||||
@ -1,7 +1,12 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -xueo pipefail
|
set -xueo pipefail
|
||||||
|
|
||||||
|
TO_PARSE="."
|
||||||
|
if [ ! -z ${1+x} ]; then
|
||||||
|
TO_PARSE="$1"
|
||||||
|
fi
|
||||||
|
|
||||||
cd $(dirname $0)
|
cd $(dirname $0)
|
||||||
for script in [0-9][0-9]_*.sh; do
|
for script in [0-9][0-9]_*.sh; do
|
||||||
./${script}
|
./${script} $TO_PARSE
|
||||||
done
|
done
|
||||||
|
|||||||
@ -15,7 +15,7 @@ function list_dirs {
|
|||||||
|
|
||||||
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]}"
|
||||||
else
|
else
|
||||||
echo "Error: impossible to parse monitor name"
|
echo "Error: impossible to parse monitor name"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user