Skip to content

Commit

Permalink
Remove shellcheck and remove values.schema.json
Browse files Browse the repository at this point in the history
Signed-off-by: QuentinBisson <[email protected]>
  • Loading branch information
QuentinBisson committed Apr 16, 2024
1 parent 5a005c6 commit e0c7da7
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 80 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# top-most EditorConfig file
root = true

[helm/dashboards/**/*.json]
[helm/dashboards/{charts, dashboards}/**/*.json]
indent_style = space
indent_size = 2
end_of_line = lf
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: pre-commit

on:
pull_request:
branches:
- main
paths:
- 'helm/dashboards/**' # helm chart directory

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: Cache pre-commit hooks
uses: actions/cache@v2
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-precommit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install pre-commit
run: pip install pre-commit
- name: Run pre-commit on changed files
run: pre-commit run --show-diff-on-failure --color=always --all-files
4 changes: 0 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
repos:
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.8.0.3
hooks:
- id: shellcheck
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: '2.7.3'
hooks:
Expand Down
102 changes: 51 additions & 51 deletions helm/dashboards/values.schema.json
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
{
"$schema": "http://json-schema.org/schema#",
"type": "object",
"properties": {
"home": {
"type": "object",
"properties": {
"urls": {
"type": "array",
"items": {
"$schema": "http://json-schema.org/schema#",
"type": "object",
"properties": {
"home": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"link": {
"type": "string"
},
"name": {
"type": "string"
},
"provider": {
"type": "string"
}
"urls": {
"type": "array",
"items": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"link": {
"type": "string"
},
"name": {
"type": "string"
},
"provider": {
"type": "string"
}
}
}
}
}
}
}
}
},
"name": {
"type": "string"
},
"namespace": {
"type": "string"
},
"project": {
"type": "object",
"properties": {
"branch": {
"type": "string"
},
"commit": {
"type": "string"
}
}
},
"provider": {
"type": "object",
"properties": {
"kind": {
"type": "string"
"name": {
"type": "string"
},
"namespace": {
"type": "string"
},
"project": {
"type": "object",
"properties": {
"branch": {
"type": "string"
},
"commit": {
"type": "string"
}
}
},
"provider": {
"type": "object",
"properties": {
"kind": {
"type": "string"
}
}
},
"serviceType": {
"type": "string"
}
}
},
"serviceType": {
"type": "string"
}
}
}
6 changes: 3 additions & 3 deletions scripts/get-dashboard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ set -e
OUTPUT=/dev/stdout

TMP=$(mktemp --tmpdir curl.XXXXXXXXXX)
trap rm -rf "$TMP" EXIT
trap "rm -rf $TMP" EXIT

HTTP_CODE=$(curl --output "$TMP" --write '%{http_code}' --silent --show-error --header "Authorization: Bearer $GRAFANA_API_KEY" https://giantswarm.grafana.net/api/dashboards/uid/"$1")
HTTP_CODE=$(curl --output "$TMP" --write '%{http_code}' --silent --show-error --header "Authorization: Bearer $GRAFANA_API_KEY" https://giantswarm.grafana.net/api/dashboards/uid/$1)
if [[ ${HTTP_CODE} -lt 200 || ${HTTP_CODE} -gt 299 ]] ; then
echo "$HTTP_CODE"
echo $HTTP_CODE
cat "$TMP"
exit 1
fi
Expand Down
4 changes: 2 additions & 2 deletions scripts/get-dashboards.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

script_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd -P)"

"$script_path"/list-dashboards.sh "$1" | while read -r d; do
$script_path/list-dashboards.sh $1 | while read d; do
uid=$(echo -n "$d" | cut -d: -f1)
echo "$d"
"$script_path"/get-dashboard.sh "$uid" "$2"
$script_path/get-dashboard.sh $uid $2
done
8 changes: 4 additions & 4 deletions scripts/make-dashboards.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ OUTPUT_DIRECTORY="./output"
echo "Cleaning output directory"
rm -rf ./$OUTPUT_DIRECTORY && mkdir ./$OUTPUT_DIRECTORY

for dashboard in "$DASHBOARD_DIRECTORY"/*; do
dashboard=$(basename "$dashboard")
for dashboard in $DASHBOARD_DIRECTORY/*; do
dashboard=$(basename $dashboard)
dashboard=${dashboard%.*}

if [ "$dashboard" = "stdlib" ]; then
Expand All @@ -19,8 +19,8 @@ for dashboard in "$DASHBOARD_DIRECTORY"/*; do
echo "Making dashboard $dashboard.jsonnet"

jsonnet \
--jpath "$GOPATH"/src/github.com/grafana/grafonnet-lib/ \
$DASHBOARD_DIRECTORY/"$dashboard".jsonnet > $OUTPUT_DIRECTORY/"$dashboard".json
--jpath $GOPATH/src/github.com/grafana/grafonnet-lib/ \
$DASHBOARD_DIRECTORY/$dashboard.jsonnet > $OUTPUT_DIRECTORY/$dashboard.json
done

echo "Made all dashboards"
2 changes: 1 addition & 1 deletion scripts/sync-kube-mixin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function tune_dashboard {

# make a temporary dir to work in
TMPDIR=$(mktemp -d -t 'tmp.XXXXXXXXXX')
trap rm -f "$TMPDIR" EXIT
trap 'rm -f $TMPDIR' EXIT
MIXIN_REPO="[email protected]:giantswarm/giantswarm-kubernetes-mixin.git"
# clone a branch of tag if provided
BRANCH=${1:-""}
Expand Down
6 changes: 3 additions & 3 deletions scripts/update-dashboard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ set -e

OUTPUT=$(mktemp --tmpdir curl.XXXXXXXXXX)
INPUT=$(mktemp --tmpdir dashboard.XXXXXXXXXX)
trap rm -rf "$INPUT" "$OUTPUT" EXIT
trap "rm -rf $INPUT $OUTPUT" EXIT

jq '.message="update by giantswarm/dashboards"' "$1" > "$INPUT"
HTTP_CODE=$(curl --output "$OUTPUT" --write '%{http_code}' --silent --show-error --request POST --data @"$INPUT" --header "Content-Type: application/json" --header "Authorization: Bearer $GRAFANA_API_KEY" https://giantswarm.grafana.net/api/dashboards/db)
jq '.message="update by giantswarm/dashboards"' $1 > $INPUT
HTTP_CODE=$(curl --output "$OUTPUT" --write '%{http_code}' --silent --show-error --request POST --data @$INPUT --header "Content-Type: application/json" --header "Authorization: Bearer $GRAFANA_API_KEY" https://giantswarm.grafana.net/api/dashboards/db)
if [[ ${HTTP_CODE} -lt 200 || ${HTTP_CODE} -gt 299 ]] ; then
echo -n "HTTP $HTTP_CODE "
cat "$OUTPUT"
Expand Down
6 changes: 3 additions & 3 deletions scripts/update-dashboards.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

script_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd -P)"

find "$1" | while read -r f; do
d=$(jq -r '.dashboard.uid + ":" + .dashboard.title' "$1/$f")
ls $1 | while read f; do
d=$(cat "$1/$f" |jq -r '.dashboard.uid + ":" + .dashboard.title')
echo "$d"
"$script_path"/update-dashboard.sh "$1/$f"
$script_path/update-dashboard.sh "$1/$f"
done
2 changes: 1 addition & 1 deletion scripts/update-monitoring-mixin-dashboards.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
set -e

TMPDIR="$(mktemp -d)"
trap rm -rf "$TMPDIR" EXIT
trap "rm -rf $TMPDIR" EXIT


main() {
Expand Down
4 changes: 2 additions & 2 deletions scripts/upload-dashboard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ GRAFANA_URL="https://giantswarm.grafana.net"
FOLDER_ID="31" # Playground folder
OUTPUT_DIRECTORY="./output"

if [ -z "$GRAFANA_API_KEY" ]; then
if [ -z $GRAFANA_API_KEY ]; then
echo "Grafana API key not set"
exit 1
fi

filename=$1
dashboard_data=$(cat "$OUTPUT_DIRECTORY"/"$filename")
dashboard_data=`cat $OUTPUT_DIRECTORY/$filename`

curl \
--header "Authorization: Bearer $GRAFANA_API_KEY" \
Expand Down
10 changes: 5 additions & 5 deletions scripts/upload-dashboards.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ GRAFANA_URL="https://giantswarm.grafana.net"
FOLDER_ID="40" # Official folder
OUTPUT_DIRECTORY="./output"

if [ -z "$GRAFANA_API_KEY" ]; then
if [ -z $GRAFANA_API_KEY ]; then
echo "Grafana API key not set"
exit 1
fi
Expand All @@ -22,17 +22,17 @@ for uid in $uids; do
curl \
--header "Authorization: Bearer $GRAFANA_API_KEY" \
--request "DELETE" \
$GRAFANA_URL/api/dashboards/uid/"$uid"
$GRAFANA_URL/api/dashboards/uid/$uid
echo
done

echo "Uploading all dashboards"

for dashboard in "$OUTPUT_DIRECTORY"/*; do
dashboard=$(basename "$dashboard")
for dashboard in $OUTPUT_DIRECTORY/*; do
dashboard=$(basename $dashboard)
dashboard=${dashboard%.*}

dashboard_data=$(cat "$OUTPUT_DIRECTORY"/"$dashboard".json)
dashboard_data=`cat $OUTPUT_DIRECTORY/$dashboard.json`

curl \
--header "Authorization: Bearer $GRAFANA_API_KEY" \
Expand Down

0 comments on commit e0c7da7

Please sign in to comment.