From 6546522968bd80630d0b8b39323af34e33bb2fb8 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sat, 12 Oct 2024 23:23:09 +0200 Subject: [PATCH] scripts: add ignore-not-found for undeploy and uninstall to Makefile boiler plate This avoid failure of any of these two commands if for some reason one or more of the kustomized resource is missing. Part of https://github.com/operator-framework/operator-sdk/issues/5195 Signed-off-by: Samuel Gaist --- .../ansible/v1/scaffolds/internal/templates/makefile.go | 8 ++++++-- testdata/memcached-molecule-operator/Makefile | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pkg/plugins/ansible/v1/scaffolds/internal/templates/makefile.go b/pkg/plugins/ansible/v1/scaffolds/internal/templates/makefile.go index 870c7be..66d2af2 100644 --- a/pkg/plugins/ansible/v1/scaffolds/internal/templates/makefile.go +++ b/pkg/plugins/ansible/v1/scaffolds/internal/templates/makefile.go @@ -119,13 +119,17 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform ##@ Deployment +ifndef ignore-not-found + ignore-not-found = false +endif + .PHONY: install install: kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config. $(KUSTOMIZE) build config/crd | kubectl apply -f - .PHONY: uninstall uninstall: kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. - $(KUSTOMIZE) build config/crd | kubectl delete -f - + $(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f - .PHONY: deploy deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. @@ -134,7 +138,7 @@ deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/c .PHONY: undeploy undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. - $(KUSTOMIZE) build config/default | kubectl delete -f - + $(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f - OS := $(shell uname -s | tr '[:upper:]' '[:lower:]') ARCH := $(shell uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/') diff --git a/testdata/memcached-molecule-operator/Makefile b/testdata/memcached-molecule-operator/Makefile index f9d5671..e77165a 100644 --- a/testdata/memcached-molecule-operator/Makefile +++ b/testdata/memcached-molecule-operator/Makefile @@ -53,13 +53,17 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform ##@ Deployment +ifndef ignore-not-found + ignore-not-found = false +endif + .PHONY: install install: kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config. $(KUSTOMIZE) build config/crd | kubectl apply -f - .PHONY: uninstall uninstall: kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. - $(KUSTOMIZE) build config/crd | kubectl delete -f - + $(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f - .PHONY: deploy deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. @@ -68,7 +72,7 @@ deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/c .PHONY: undeploy undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. - $(KUSTOMIZE) build config/default | kubectl delete -f - + $(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f - OS := $(shell uname -s | tr '[:upper:]' '[:lower:]') ARCH := $(shell uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')