|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -x |
| 4 | + |
| 5 | +# Patch catalogd rbac |
| 6 | +catalogd_rbac_filelist=( |
| 7 | + helm/olmv1/base/catalogd/rbac/experimental/*.yaml |
| 8 | + helm/olmv1/base/catalogd/rbac/standard/*.yaml |
| 9 | +) |
| 10 | +for f in "${catalogd_rbac_filelist[@]}"; do |
| 11 | + yq -i '.metadata.labels["app.kubernetes.io/name"] = "catalogd"' "${f}" |
| 12 | + rm "${f}.bak" |
| 13 | +done |
| 14 | + |
| 15 | +# Patch operator-controller rbac |
| 16 | +operator_controller_rbac_filelist=( |
| 17 | + helm/olmv1/base/operator-controller/rbac/experimental/*.yaml |
| 18 | + helm/olmv1/base/operator-controller/rbac/standard/*.yaml |
| 19 | +) |
| 20 | +for f in "${operator_controller_rbac_filelist[@]}"; do |
| 21 | + yq -i '.metadata.labels["app.kubernetes.io/name"] = "operator-controller"' "${f}" |
| 22 | + rm "${f}.bak" |
| 23 | +done |
| 24 | + |
| 25 | +# Patch catalogd webhook |
| 26 | +catalogd_webhook_filelist=( |
| 27 | + helm/olmv1/base/catalogd/webhook/experimental/*.yaml |
| 28 | + helm/olmv1/base/catalogd/webhook/standard/*.yaml |
| 29 | +) |
| 30 | +for f in "${catalogd_webhook_filelist[@]}"; do |
| 31 | + yq -i '.metadata.labels["app.kubernetes.io/name"] = "catalogd"' "${f}" |
| 32 | + yq -i '.metadata.name = "catalogd-mutating-webhook-configuration"' "${f}" |
| 33 | + # This really only applies to cert-manager configs, but it's an annotation |
| 34 | + yq -i '.metadata.annotations["cert-manager.io/inject-ca-from-secret"] = "cert-manager/olmv1-ca"' "${f}" |
| 35 | + yq -i '.webhooks[0].clientConfig.service.namespace = "olmv1-system"' "${f}" |
| 36 | + yq -i '.webhooks[0].clientConfig.service.name = "catalogd-service"' "${f}" |
| 37 | + yq -i '.webhooks[0].clientConfig.service.port = 9443' "${f}" |
| 38 | + yq -i '.webhooks[0].matchConditions[0].name = "MissingOrIncorrectMetadataNameLabel"' "${f}" |
| 39 | + yq -i '.webhooks[0].matchConditions[0].expression = "\"name\" in object.metadata && (!has(object.metadata.labels) || !(\"olm.operatorframework.io/metadata.name\" in object.metadata.labels) || object.metadata.labels[\"olm.operatorframework.io/metadata.name\"] != object.metadata.name)"' "${f}" |
| 40 | + rm "${f}.bak" |
| 41 | +done |
| 42 | + |
| 43 | +# Patch everything genericly |
| 44 | +filelist=( |
| 45 | + helm/olmv1/base/catalogd/rbac/experimental/*.yaml |
| 46 | + helm/olmv1/base/catalogd/rbac/standard/*.yaml |
| 47 | + helm/olmv1/base/catalogd/crd/experimental/*.yaml |
| 48 | + helm/olmv1/base/catalogd/crd/standard/*.yaml |
| 49 | + helm/olmv1/base/catalogd/webhook/experimental/*.yaml |
| 50 | + helm/olmv1/base/catalogd/webhook/standard/*.yaml |
| 51 | + helm/olmv1/base/operator-controller/rbac/experimental/*.yaml |
| 52 | + helm/olmv1/base/operator-controller/rbac/standard/*.yaml |
| 53 | + helm/olmv1/base/operator-controller/crd/experimental/*.yaml |
| 54 | + helm/olmv1/base/operator-controller/crd/standard/*.yaml |
| 55 | +) |
| 56 | + |
| 57 | +for f in "${filelist[@]}"; do |
| 58 | + # Patch in the temporary items |
| 59 | + yq -i '.metadata.annotations.replaceMe = "annotations"' "${f}" |
| 60 | + yq -i '.metadata.labels.replaceMe = "labels"' "${f}" |
| 61 | + # Replace with helm template - must be done last or yq will complain about the file format |
| 62 | + sed -i.bak 's/replaceMe: annotations/{{- include "olmv1.annotations" . | nindent 4 }}/g' "${f}" |
| 63 | + sed -i.bak 's/replaceMe: labels/{{- include "olmv1.labels" . | nindent 4 }}/g' "${f}" |
| 64 | + sed -i.bak 's/olmv1-system/{{ .Values.namespaces.olmv1.name }}/g' "${f}" |
| 65 | + # Delete sed's backup file |
| 66 | + rm "${f}.bak" |
| 67 | +done |
0 commit comments