Skip to content

Commit 352c579

Browse files
Merge pull request #277 from abays/olm_webhook_cleanup
Automate OLM cleanup for running local operator w/ webhooks
2 parents b0954ab + 5d5d976 commit 352c579

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,11 @@ gowork: ## Generate go.work file
366366
go work sync
367367

368368
# Used for webhook testing
369-
# Please ensure the mariadb-controller-manager deployment and
370-
# webhook definitions are removed from the csv before running
371-
# this. Also, cleanup the webhook configuration for local testing
372-
# before deplying with olm again.
373-
# $oc delete -n openstack validatingwebhookconfiguration/vmariadb.kb.io
374-
# $oc delete -n openstack mutatingwebhookconfiguration/mmariadb.kb.io
369+
# The configure_local_webhooks.sh script below will remove any OLM webhooks
370+
# for the operator and also scale its deployment replicas down to 0 so that
371+
# the operator can run locally.
372+
# Make sure to cleanup the webhook configuration for local testing by running
373+
# ./hack/clean_local_webhook.sh before deplying with OLM again.
375374
SKIP_CERT ?=false
376375
.PHONY: run-with-webhook
377376
run-with-webhook: export METRICS_PORT?=8080

hack/configure_local_webhook.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,11 @@ webhooks:
131131
EOF_CAT
132132

133133
oc apply -n openstack -f ${TMPDIR}/patch_webhook_configurations.yaml
134+
135+
# Scale-down operator deployment replicas to zero and remove OLM webhooks
136+
CSV_NAME="$(oc get csv -n openstack-operators -l operators.coreos.com/mariadb-operator.openstack-operators -o name)"
137+
138+
if [ -n "${CSV_NAME}" ]; then
139+
oc patch "${CSV_NAME}" -n openstack-operators --type=json -p="[{'op': 'replace', 'path': '/spec/install/spec/deployments/0/spec/replicas', 'value': 0}]"
140+
oc patch "${CSV_NAME}" -n openstack-operators --type=json -p="[{'op': 'replace', 'path': '/spec/webhookdefinitions', 'value': []}]"
141+
fi

0 commit comments

Comments
 (0)