-
Notifications
You must be signed in to change notification settings - Fork 5.2k
/
Copy pathupdate_crds.sh
executable file
·47 lines (37 loc) · 1.85 KB
/
update_crds.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
set -e
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
if [[ $(uname -s) = "Darwin" ]]; then
VERSION="$(grep ^appVersion "${SCRIPT_DIR}/../Chart.yaml" | sed 's/appVersion: //g')"
else
VERSION="$(grep ^appVersion "${SCRIPT_DIR}/../Chart.yaml" | sed 's/appVersion:\s//g')"
fi
FILES=(
"crd-alertmanagerconfigs.yaml : monitoring.coreos.com_alertmanagerconfigs.yaml"
"crd-alertmanagers.yaml : monitoring.coreos.com_alertmanagers.yaml"
"crd-podmonitors.yaml : monitoring.coreos.com_podmonitors.yaml"
"crd-probes.yaml : monitoring.coreos.com_probes.yaml"
"crd-prometheusagents.yaml : monitoring.coreos.com_prometheusagents.yaml"
"crd-prometheuses.yaml : monitoring.coreos.com_prometheuses.yaml"
"crd-prometheusrules.yaml : monitoring.coreos.com_prometheusrules.yaml"
"crd-scrapeconfigs.yaml : monitoring.coreos.com_scrapeconfigs.yaml"
"crd-servicemonitors.yaml : monitoring.coreos.com_servicemonitors.yaml"
"crd-thanosrulers.yaml : monitoring.coreos.com_thanosrulers.yaml"
)
for line in "${FILES[@]}"; do
DESTINATION=$(echo "${line%%:*}" | xargs)
SOURCE=$(echo "${line##*:}" | xargs)
URL="https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/$VERSION/example/prometheus-operator-crd/$SOURCE"
echo -e "Downloading Prometheus Operator CRD with Version ${VERSION}:\n${URL}\n"
echo "# ${URL}" >"${SCRIPT_DIR}/../charts/crds/crds/${DESTINATION}"
if ! curl --silent --retry-all-errors --fail --location "${URL}" >>"${SCRIPT_DIR}/../charts/crds/crds/${DESTINATION}"; then
echo -e "Failed to download ${URL}!"
exit 1
fi
done
{
for file in "${SCRIPT_DIR}/../charts/crds/crds/"crd*.yaml; do
cat "${file}"
echo "---"
done
} | bzip2 --best --compress --keep --stdout - >"${SCRIPT_DIR}/../charts/crds/files/crds.bz2"