diff --git a/staging/prometheus-operator/patch/helpers.sh b/staging/prometheus-operator/patch/helpers.sh index 4d70a7dff..c02dd1f87 100755 --- a/staging/prometheus-operator/patch/helpers.sh +++ b/staging/prometheus-operator/patch/helpers.sh @@ -4,6 +4,14 @@ function git_add_and_commit { FILES_PATH=$1 git add ${FILES_PATH} FILENAME=$(basename "$0") - git commit -m "Apply ${FILENAME}" + git commit -m "chore: apply ${FILENAME}" +} + +function git_add_and_commit_with_msg { + FILES_PATH=$1 + MSG=$2 + git add ${FILES_PATH} + FILENAME=$(basename "$0") + git commit -m "chore: apply ${FILENAME} - ${MSG}" } diff --git a/staging/prometheus-operator/patch/patch_7_prometheus_crd.sh b/staging/prometheus-operator/patch/patch_7_prometheus_crd.sh index 477879764..a537fbfa0 100755 --- a/staging/prometheus-operator/patch/patch_7_prometheus_crd.sh +++ b/staging/prometheus-operator/patch/patch_7_prometheus_crd.sh @@ -1,14 +1,30 @@ #!/bin/bash +source $(dirname "$0")/helpers.sh + set -x -if [[ -z $(command -v yq) ]]; then - echo "$0 requires the 'yq' command line tool which is not installed. Please install this and start again." - exit 1 -fi +SRCFILE=crds/crd-prometheus.yaml +TMPFILE=crds/tmp-prom.yaml + +docker run --rm -it \ + -v ${BASEDIR}:/basedir \ + -w /basedir \ + -e SRCFILE=${SRCFILE} \ + -e TMPFILE=${TMPFILE} \ + mikefarah/yq:3.3.2 \ + yq read -P "${SRCFILE}" > "${TMPFILE}" && mv "${TMPFILE}" "${SRCFILE}" + +git_add_and_commit_with_msg ${SRCFILE} "reformat yaml with yq" + +docker run --rm -it \ + -v ${BASEDIR}:/basedir \ + -w /basedir \ + -e SRCFILE=${SRCFILE} \ + -e TMPFILE=${TMPFILE} \ + mikefarah/yq:3.3.2 \ + yq write -i "${SRCFILE}" spec.validation.openAPIV3Schema.properties.spec.properties.storage.properties.volumeClaimTemplate.properties.metadata.properties.name.description "Name is the name used in the PVC claim" && \ + yq write -i "${SRCFILE}" spec.validation.openAPIV3Schema.properties.spec.properties.storage.properties.volumeClaimTemplate.properties.metadata.properties.name.type "string" -SRCFILE="${BASEDIR}/crds/crd-prometheus.yaml" -TMPFILE=$(mktemp) -yq -y '.spec.validation.openAPIV3Schema.properties.spec.properties.storage.properties.volumeClaimTemplate.properties.metadata.properties.name = {"description": "Name is the name used in the PVC claim", "type": "string"}' ${SRCFILE} >> ${TMPFILE} -mv ${TMPFILE} ${SRCFILE} +git_add_and_commit_with_msg ${SRCFILE} "update volumeClaimTemplate"