1
1
#!/bin/bash
2
+ set -euo pipefail
2
3
3
4
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
4
5
8
9
VERSION="$(grep ^appVersion "${SCRIPT_DIR}/../Chart.yaml" | sed 's/appVersion:\s//g')"
9
10
fi
10
11
11
- FILES =(
12
- "crd- alertmanagerconfigs.yaml : monitoring.coreos.com_alertmanagerconfigs.yaml"
13
- "crd- alertmanagers.yaml : monitoring.coreos.com_alertmanagers.yaml"
14
- "crd- podmonitors.yaml : monitoring.coreos.com_podmonitors.yaml"
15
- "crd- probes.yaml : monitoring.coreos.com_probes.yaml"
16
- "crd- prometheusagents.yaml : monitoring.coreos.com_prometheusagents.yaml"
17
- "crd- prometheuses.yaml : monitoring.coreos.com_prometheuses.yaml"
18
- "crd- prometheusrules.yaml : monitoring.coreos.com_prometheusrules.yaml"
19
- "crd- scrapeconfigs.yaml : monitoring.coreos.com_scrapeconfigs.yaml"
20
- "crd- servicemonitors.yaml : monitoring.coreos.com_servicemonitors.yaml"
21
- "crd- thanosrulers.yaml : monitoring.coreos.com_thanosrulers.yaml"
12
+ CRDS =(
13
+ "alertmanagerconfigs : monitoring.coreos.com_alertmanagerconfigs.yaml"
14
+ "alertmanagers : monitoring.coreos.com_alertmanagers.yaml"
15
+ "podmonitors : monitoring.coreos.com_podmonitors.yaml"
16
+ "probes : monitoring.coreos.com_probes.yaml"
17
+ "prometheusagents : monitoring.coreos.com_prometheusagents.yaml"
18
+ "prometheuses : monitoring.coreos.com_prometheuses.yaml"
19
+ "prometheusrules : monitoring.coreos.com_prometheusrules.yaml"
20
+ "scrapeconfigs : monitoring.coreos.com_scrapeconfigs.yaml"
21
+ "servicemonitors : monitoring.coreos.com_servicemonitors.yaml"
22
+ "thanosrulers : monitoring.coreos.com_thanosrulers.yaml"
22
23
)
23
24
24
- for line in "${FILES [@]}"; do
25
- DESTINATION =$(echo "${line%%:*}" | xargs)
25
+ for line in "${CRDS [@]}"; do
26
+ CRD =$(echo "${line%%:*}" | xargs)
26
27
SOURCE=$(echo "${line##*:}" | xargs)
28
+ DESTINATION="crd-${CRD}".yaml
27
29
28
30
URL="https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/$VERSION/example/prometheus-operator-crd/$SOURCE"
29
31
@@ -42,4 +44,8 @@ for line in "${FILES[@]}"; do
42
44
else
43
45
sed -i '/^metadata:$/a {{- with .Values.annotations }}\n annotations:\n{{- toYaml . | nindent 4 }}\n{{- end }}' "${SCRIPT_DIR}/../charts/crds/templates/${DESTINATION}"
44
46
fi
47
+
48
+ # Insert enable option
49
+ sed -i "1i\{{- if .Values.${CRD}.enabled -}}" "${SCRIPT_DIR}/../charts/crds/templates/${DESTINATION}"
50
+ echo "{{- end -}}" >> "${SCRIPT_DIR}/../charts/crds/templates/${DESTINATION}"
45
51
done
0 commit comments