2023-08-20 16:55:23 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -ex
|
|
|
|
|
2023-08-21 11:56:56 +00:00
|
|
|
# prometheus metrics mixin branch
|
|
|
|
# https://github.com/prometheus-operator/kube-prometheus#compatibility
|
|
|
|
KUBE_PROMETHEUS_RELEASE=main
|
2023-08-20 16:55:23 +00:00
|
|
|
|
2023-08-21 11:56:56 +00:00
|
|
|
update_jsonnet() {
|
|
|
|
which jsonnet > /dev/null || { echo "Required jsonnet not found!"; exit 1;}
|
|
|
|
which jb > /dev/null || { echo "Required jb ( json-bundler ) not found!"; exit 1;}
|
|
|
|
|
|
|
|
# remove previous versions
|
|
|
|
rm -f jsonnetfile.json jsonnetfile.lock.json
|
|
|
|
|
|
|
|
jb init
|
|
|
|
jb install github.com/prometheus-operator/kube-prometheus/jsonnet/kube-prometheus@main
|
|
|
|
}
|
2023-08-20 16:55:23 +00:00
|
|
|
|
2023-08-21 11:56:56 +00:00
|
|
|
update_helm() {
|
|
|
|
#helm repo update
|
|
|
|
helm dep update
|
|
|
|
}
|
|
|
|
|
|
|
|
# AWS public ECR
|
|
|
|
login_ecr_public() {
|
|
|
|
aws ecr-public get-login-password \
|
|
|
|
--region us-east-1 | helm registry login \
|
|
|
|
--username AWS \
|
|
|
|
--password-stdin public.ecr.aws
|
|
|
|
}
|
2023-08-20 16:55:23 +00:00
|
|
|
|
2024-04-04 13:39:36 +00:00
|
|
|
get_extract_chart() {
|
2023-08-23 11:37:57 +00:00
|
|
|
local CHART=$1
|
|
|
|
local VERSION=$(yq eval '.dependencies[] | select(.name=="'$CHART'") | .version' Chart.yaml)
|
2023-08-20 16:55:23 +00:00
|
|
|
|
|
|
|
rm -rf charts/$CHART
|
2023-08-23 11:37:57 +00:00
|
|
|
|
|
|
|
# If helm already pulled the chart archive use it
|
|
|
|
if [ -f charts/$CHART-$VERSION.tgz ]; then
|
|
|
|
tar xfvz charts/$CHART-$VERSION.tgz -C charts && rm charts/$CHART-$VERSION.tgz
|
|
|
|
|
|
|
|
# otherwise parse Chart.yaml and get it
|
|
|
|
else
|
2024-04-04 13:39:36 +00:00
|
|
|
local REPO=$(yq eval '.dependencies[] | select(.name=="'$CHART'") | .repository' Chart.yaml)
|
|
|
|
local URL=$(curl -s $REPO/index.yaml | yq '.entries."'$CHART'".[] | select (.version=="'$VERSION'") | .urls[0]')
|
|
|
|
|
|
|
|
wget -qO - $URL | tar xfvz - -C charts
|
2023-08-23 11:37:57 +00:00
|
|
|
fi
|
2024-04-04 13:39:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
patch_chart() {
|
|
|
|
local CHART=$1
|
|
|
|
|
|
|
|
get_extract_chart $CHART
|
2023-08-20 16:55:23 +00:00
|
|
|
|
2023-08-21 17:24:01 +00:00
|
|
|
[ -r $CHART.patch ] && patch -p0 -i $CHART.patch --no-backup-if-mismatch || true
|
2023-08-20 16:55:23 +00:00
|
|
|
}
|
2023-08-21 09:49:57 +00:00
|
|
|
|
2023-08-23 11:37:57 +00:00
|
|
|
patch_rebase() {
|
|
|
|
local CHART=$1
|
|
|
|
|
2024-04-04 13:39:36 +00:00
|
|
|
get_extract_chart $CHART
|
|
|
|
|
2023-08-23 11:37:57 +00:00
|
|
|
cp -r charts/$CHART charts/$CHART.orig
|
|
|
|
|
|
|
|
patch -p0 -i $CHART.patch --no-backup-if-mismatch
|
|
|
|
}
|
|
|
|
|
|
|
|
patch_create() {
|
|
|
|
local CHART=$1
|
|
|
|
|
|
|
|
diff -rtuN charts/$CHART.orig charts/$CHART > $CHART.patch
|
|
|
|
rm -rf charts/$CHART.orig
|
|
|
|
}
|
|
|
|
|
2023-08-21 09:49:57 +00:00
|
|
|
update_docs() {
|
|
|
|
helm-docs
|
|
|
|
}
|