chore: automate updating etc/telegraf.conf and etc/telegraf_windows.conf (#9684)
This commit is contained in:
parent
1c0b74eacd
commit
027647e3ed
|
|
@ -25,6 +25,23 @@ executors:
|
|||
GOFLAGS: -p=8
|
||||
|
||||
commands:
|
||||
generate-config:
|
||||
parameters:
|
||||
os:
|
||||
type: string
|
||||
default: "linux"
|
||||
steps:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: '/build'
|
||||
- run: ./scripts/generate_config.sh << parameters.os >>
|
||||
- store_artifacts:
|
||||
path: './new-config'
|
||||
destination: 'new-config'
|
||||
- persist_to_workspace:
|
||||
root: './new-config'
|
||||
paths:
|
||||
- '*'
|
||||
check-changed-files-or-halt:
|
||||
steps:
|
||||
- run: ./scripts/check-file-changes.sh
|
||||
|
|
@ -335,6 +352,24 @@ jobs:
|
|||
PR=${CIRCLE_PULL_REQUEST##*/}
|
||||
printf -v payload '{ "pullRequestNumber": "%s" }' "$PR"
|
||||
curl -X POST "https://182c7jdgog.execute-api.us-east-1.amazonaws.com/prod/shareArtifacts" --data "$payload"
|
||||
generate-config:
|
||||
executor: go-1_17
|
||||
steps:
|
||||
- generate-config
|
||||
generate-config-win:
|
||||
executor:
|
||||
name: win/default
|
||||
shell: bash.exe
|
||||
steps:
|
||||
- generate-config:
|
||||
os: windows
|
||||
update-config:
|
||||
executor: go-1_17
|
||||
steps:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: '/new-config'
|
||||
- run: ./scripts/update_config.sh ${UPDATE_CONFIG_TOKEN}
|
||||
|
||||
commonjobs:
|
||||
- &test-awaiter
|
||||
|
|
@ -446,6 +481,28 @@ workflows:
|
|||
- *static-package
|
||||
- *mipsel-package
|
||||
- *mips-package
|
||||
- 'generate-config':
|
||||
requires:
|
||||
- 'amd64-package'
|
||||
filters:
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- 'generate-config-win':
|
||||
requires:
|
||||
- 'windows-package'
|
||||
filters:
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- 'update-config':
|
||||
requires:
|
||||
- 'generate-config-win'
|
||||
- 'generate-config'
|
||||
filters:
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- 'share-artifacts':
|
||||
requires:
|
||||
- 'i386-package'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
#!/bin/bash
|
||||
# This script is responsible for generating the Telegraf config found under the `etc` directory.
|
||||
# This script is meant to be only ran in within the Circle CI pipeline so that the Tiger Bot can update them automatically.
|
||||
# It supports Windows and Linux because the configs are different depending on the OS.
|
||||
|
||||
|
||||
os=$1 # windows or linux
|
||||
exe_path="/build/extracted" # Path will contain telegraf binary
|
||||
config_name="telegraf.conf"
|
||||
|
||||
if [ "$os" = "windows" ]; then
|
||||
zip=$(/bin/find ./build/dist -maxdepth 1 -name "*windows_amd64.zip" -print)
|
||||
exe_path="$PWD/build/extracted"
|
||||
unzip "$zip" -d "$exe_path"
|
||||
config_name="telegraf_windows.conf"
|
||||
exe_path=$(/bin/find "$exe_path" -name telegraf.exe -type f -print)
|
||||
else
|
||||
tar_path=$(find /build/dist -maxdepth 1 -name "*linux_amd64.tar.gz" -print | grep -v ".*static.*")
|
||||
mkdir "$exe_path"
|
||||
tar --extract --file="$tar_path" --directory "$exe_path"
|
||||
exe_path=$(find "$exe_path" -name telegraf -type f -print | grep ".*usr/bin/.*")
|
||||
fi
|
||||
|
||||
$exe_path config > $config_name
|
||||
|
||||
mkdir ./new-config
|
||||
mv $config_name ./new-config
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
# This script is responsible for triggering the Tiger Bot endpoint that will create the pull request with the newly generated configs.
|
||||
# This script is meant to be only ran in within the Circle CI pipeline.
|
||||
|
||||
token=$1
|
||||
|
||||
config_path="/new-config"
|
||||
|
||||
if [ ! -f "$config_path/telegraf.conf" ]; then
|
||||
echo "$config_path/telegraf.conf does not exist"
|
||||
exit
|
||||
fi
|
||||
if [ ! -f "$config_path/telegraf_windows.conf" ]; then
|
||||
echo "$config_path/telegraf_windows.conf does not exist"
|
||||
exit
|
||||
fi
|
||||
|
||||
if cmp -s "$config_path/telegraf.conf" "etc/telegraf.conf" && cmp -s "$config_path/telegraf_windows.conf" "etc/telegraf_windows.conf"; then
|
||||
echo "Both telegraf.conf and telegraf_windows.conf haven't changed"
|
||||
fi
|
||||
|
||||
curl -H "Authorization: Bearer $token" -X POST "https://182c7jdgog.execute-api.us-east-1.amazonaws.com/prod/updateConfig"
|
||||
Loading…
Reference in New Issue