11#! /bin/bash
22set -euo pipefail
33
4- SCRIPT_DIR=$( cd -- " $( dirname -- " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd )
4+ SCRIPT_DIR=$( cd -- " $( dirname -- " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd)
55
66if [[ $( uname -s) = " Darwin" ]]; then
7- VERSION=" $( grep ^appVersion " ${SCRIPT_DIR} /../Chart.yaml" | sed ' s/appVersion: //g' ) "
7+ VERSION=" $( grep ^appVersion " ${SCRIPT_DIR} /../Chart.yaml" | sed ' s/appVersion: //g' ) "
88else
9- VERSION=" $( grep ^appVersion " ${SCRIPT_DIR} /../Chart.yaml" | sed ' s/appVersion:\s//g' ) "
9+ VERSION=" $( grep ^appVersion " ${SCRIPT_DIR} /../Chart.yaml" | sed ' s/appVersion:\s//g' ) "
1010fi
1111
1212CRDS=(
@@ -23,29 +23,29 @@ CRDS=(
2323)
2424
2525for line in " ${CRDS[@]} " ; do
26- CRD=$( echo " ${line%%:* } " | xargs)
27- SOURCE=$( echo " ${line##*: } " | xargs)
28- DESTINATION=" crd-${CRD} " .yaml
26+ CRD=$( echo " ${line%%:* } " | xargs)
27+ SOURCE=$( echo " ${line##*: } " | xargs)
28+ DESTINATION=" crd-${CRD} " .yaml
2929
30- URL=" https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/$VERSION /example/prometheus-operator-crd/$SOURCE "
30+ URL=" https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/$VERSION /example/prometheus-operator-crd/$SOURCE "
3131
32- echo -e " Downloading Prometheus Operator CRD with Version ${VERSION} :\n${URL} \n"
32+ echo -e " Downloading Prometheus Operator CRD with Version ${VERSION} :\n${URL} \n"
3333
34- echo " # ${URL} " > " ${SCRIPT_DIR} /../charts/crds/templates/${DESTINATION} "
34+ echo " # ${URL} " > " ${SCRIPT_DIR} /../charts/crds/templates/${DESTINATION} "
3535
36- if ! curl --silent --retry-all-errors --fail --location " ${URL} " >> " ${SCRIPT_DIR} /../charts/crds/templates/${DESTINATION} " ; then
37- echo -e " Failed to download ${URL} !"
38- exit 1
39- fi
36+ if ! curl --silent --retry-all-errors --fail --location " ${URL} " >> " ${SCRIPT_DIR} /../charts/crds/templates/${DESTINATION} " ; then
37+ echo -e " Failed to download ${URL} !"
38+ exit 1
39+ fi
4040
41- # Update or insert annotations block
42- if yq -e ' .metadata.annotations' " ${SCRIPT_DIR} /../charts/crds/templates/${DESTINATION} " > /dev/null; then
43- sed -i ' /^ annotations:$/a {{- with .Values.annotations }}\n{{- toYaml . | nindent 4 }}\n{{- end }}' " ${SCRIPT_DIR} /../charts/crds/templates/${DESTINATION} "
44- else
45- sed -i ' /^metadata:$/a {{- with .Values.annotations }}\n annotations:\n{{- toYaml . | nindent 4 }}\n{{- end }}' " ${SCRIPT_DIR} /../charts/crds/templates/${DESTINATION} "
46- fi
41+ # Update or insert annotations block
42+ if yq -e ' .metadata.annotations' " ${SCRIPT_DIR} /../charts/crds/templates/${DESTINATION} " > /dev/null; then
43+ sed -i ' /^ annotations:$/a {{- with .Values.annotations }}\n{{- toYaml . | nindent 4 }}\n{{- end }}' " ${SCRIPT_DIR} /../charts/crds/templates/${DESTINATION} "
44+ else
45+ sed -i ' /^metadata:$/a {{- with .Values.annotations }}\n annotations:\n{{- toYaml . | nindent 4 }}\n{{- end }}' " ${SCRIPT_DIR} /../charts/crds/templates/${DESTINATION} "
46+ fi
4747
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} "
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} "
5151done
0 commit comments