2018-07-16 03:53:41 -05:00
|
|
|
#!/bin/bash
|
2018-05-29 07:00:46 -05:00
|
|
|
|
|
|
|
bulkDashboard() {
|
|
|
|
|
2018-06-21 09:18:46 -05:00
|
|
|
requiresJsonnet
|
2018-05-29 07:00:46 -05:00
|
|
|
|
2018-06-21 09:18:46 -05:00
|
|
|
COUNTER=0
|
|
|
|
MAX=400
|
|
|
|
while [ $COUNTER -lt $MAX ]; do
|
2018-08-20 12:21:32 -05:00
|
|
|
jsonnet -o "bulk-dashboards/dashboard${COUNTER}.json" -e "local bulkDash = import 'bulk-dashboards/bulkdash.jsonnet'; bulkDash + { uid: 'uid-${COUNTER}', title: 'title-${COUNTER}' }"
|
2018-06-21 09:18:46 -05:00
|
|
|
let COUNTER=COUNTER+1
|
|
|
|
done
|
2018-05-29 07:00:46 -05:00
|
|
|
|
2018-09-25 07:02:55 -05:00
|
|
|
ln -s -f ../../../devenv/bulk-dashboards/bulk-dashboards.yaml ../conf/provisioning/dashboards/custom.yaml
|
2018-05-29 07:00:46 -05:00
|
|
|
}
|
|
|
|
|
2023-09-26 07:05:37 -05:00
|
|
|
bulkFolders() {
|
|
|
|
./bulk-folders/bulk-folders.sh "$1"
|
|
|
|
ln -s -f ../../../devenv/bulk-folders/bulk-folders.yaml ../conf/provisioning/dashboards/bulk-folders.yaml
|
|
|
|
}
|
|
|
|
|
2018-05-29 07:00:46 -05:00
|
|
|
requiresJsonnet() {
|
2018-06-21 09:18:46 -05:00
|
|
|
if ! type "jsonnet" > /dev/null; then
|
|
|
|
echo "you need you install jsonnet to run this script"
|
|
|
|
echo "follow the instructions on https://github.com/google/jsonnet"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-05-29 07:00:46 -05:00
|
|
|
}
|
|
|
|
|
2018-07-16 03:53:41 -05:00
|
|
|
devDashboards() {
|
|
|
|
echo -e "\xE2\x9C\x94 Setting up all dev dashboards using provisioning"
|
2018-07-07 07:40:17 -05:00
|
|
|
ln -s -f ../../../devenv/dashboards.yaml ../conf/provisioning/dashboards/dev.yaml
|
2018-05-29 07:00:46 -05:00
|
|
|
}
|
|
|
|
|
2018-07-16 03:53:41 -05:00
|
|
|
devDatasources() {
|
|
|
|
echo -e "\xE2\x9C\x94 Setting up all dev datasources using provisioning"
|
2018-05-29 07:00:46 -05:00
|
|
|
|
2018-07-07 07:40:17 -05:00
|
|
|
ln -s -f ../../../devenv/datasources.yaml ../conf/provisioning/datasources/dev.yaml
|
2018-05-29 07:00:46 -05:00
|
|
|
}
|
|
|
|
|
2023-10-18 08:05:59 -05:00
|
|
|
undev() {
|
|
|
|
echo -e "\xE2\x9C\x94 Reverting all dev provisioning"
|
|
|
|
|
|
|
|
# Removing generated dashboard files from bulk-dashboards
|
|
|
|
rm -f bulk-dashboards/dashboard*.json
|
|
|
|
echo -e " \xE2\x9C\x94 Reverting bulk-dashboards provisioning"
|
|
|
|
|
|
|
|
# Removing generated folders from bulk-folders
|
|
|
|
rm -rf bulk-folders/Bulk\ Folder*
|
|
|
|
echo -e " \xE2\x9C\x94 Reverting bulk-folders provisioning"
|
|
|
|
|
|
|
|
# Removing the symlinks
|
|
|
|
rm -f ../conf/provisioning/dashboards/custom.yaml
|
|
|
|
rm -f ../conf/provisioning/dashboards/bulk-folders.yaml
|
|
|
|
rm -f ../conf/provisioning/dashboards/dev.yaml
|
|
|
|
rm -f ../conf/provisioning/datasources/custom.yaml
|
|
|
|
rm -f ../conf/provisioning/datasources/dev.yaml
|
|
|
|
}
|
|
|
|
|
2018-05-29 07:00:46 -05:00
|
|
|
usage() {
|
2018-07-16 03:53:41 -05:00
|
|
|
echo -e "\n"
|
2018-05-29 07:00:46 -05:00
|
|
|
echo "Usage:"
|
2023-09-26 07:05:37 -05:00
|
|
|
echo " bulk-dashboards - provision 400 dashboards"
|
|
|
|
echo " bulk-folders [folders] [dashboards] - provision many folders with dashboards"
|
|
|
|
echo " bulk-folders - provision 200 folders with 3 dashboards in each"
|
|
|
|
echo " no args - provision core datasources and dev dashboards"
|
2023-10-18 08:05:59 -05:00
|
|
|
echo " undev - removes any provisioning done by the setup.sh"
|
2018-05-29 07:00:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
2023-09-26 07:05:37 -05:00
|
|
|
echo -e "----------------------------------------------------------------------------"
|
|
|
|
echo -e "This script sets up provisioning for dev datasources, dashboards and folders"
|
|
|
|
echo -e "----------------------------------------------------------------------------"
|
2018-07-16 03:53:41 -05:00
|
|
|
echo -e "\n"
|
|
|
|
|
2018-05-29 07:00:46 -05:00
|
|
|
local cmd=$1
|
2023-09-26 07:05:37 -05:00
|
|
|
local arg1=$2
|
2018-05-29 07:00:46 -05:00
|
|
|
|
2024-03-14 09:36:35 -05:00
|
|
|
if [[ $cmd == "bulk-dashboards" ]]; then
|
2018-05-29 07:00:46 -05:00
|
|
|
bulkDashboard
|
2023-09-26 07:05:37 -05:00
|
|
|
elif [[ $cmd == "bulk-folders" ]]; then
|
|
|
|
bulkFolders "$arg1"
|
2023-10-18 08:05:59 -05:00
|
|
|
elif [[ $cmd == "undev" ]]; then
|
|
|
|
undev
|
2018-05-29 07:00:46 -05:00
|
|
|
else
|
2018-07-16 03:53:41 -05:00
|
|
|
devDashboards
|
|
|
|
devDatasources
|
2018-07-07 07:40:17 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "$cmd" ]]; then
|
2018-05-29 07:00:46 -05:00
|
|
|
usage
|
|
|
|
fi
|
2018-07-07 07:40:17 -05:00
|
|
|
|
2018-05-29 07:00:46 -05:00
|
|
|
}
|
|
|
|
|
2018-05-31 07:13:34 -05:00
|
|
|
main "$@"
|