Skip to content

Commit 10af011

Browse files
authored
scripts: add ignore-not-found for undeploy and uninstall to Makefile boiler plate (#106)
This avoid failure of any of these two commands if for some reason one or more of the kustomized resource is missing. Part of operator-framework/operator-sdk#5195 Signed-off-by: Samuel Gaist <[email protected]>
1 parent 54d3fc8 commit 10af011

File tree

2 files changed

+12
-4
lines changed
  • pkg/plugins/ansible/v1/scaffolds/internal/templates
  • testdata/memcached-molecule-operator

2 files changed

+12
-4
lines changed

pkg/plugins/ansible/v1/scaffolds/internal/templates/makefile.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,17 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
119119
120120
##@ Deployment
121121
122+
ifndef ignore-not-found
123+
ignore-not-found = false
124+
endif
125+
122126
.PHONY: install
123127
install: kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
124128
$(KUSTOMIZE) build config/crd | kubectl apply -f -
125129
126130
.PHONY: uninstall
127131
uninstall: kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
128-
$(KUSTOMIZE) build config/crd | kubectl delete -f -
132+
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
129133
130134
.PHONY: deploy
131135
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
134138
135139
.PHONY: undeploy
136140
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
137-
$(KUSTOMIZE) build config/default | kubectl delete -f -
141+
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
138142
139143
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
140144
ARCH := $(shell uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')

testdata/memcached-molecule-operator/Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,17 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
5353

5454
##@ Deployment
5555

56+
ifndef ignore-not-found
57+
ignore-not-found = false
58+
endif
59+
5660
.PHONY: install
5761
install: kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
5862
$(KUSTOMIZE) build config/crd | kubectl apply -f -
5963

6064
.PHONY: uninstall
6165
uninstall: kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
62-
$(KUSTOMIZE) build config/crd | kubectl delete -f -
66+
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
6367

6468
.PHONY: deploy
6569
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
6872

6973
.PHONY: undeploy
7074
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
71-
$(KUSTOMIZE) build config/default | kubectl delete -f -
75+
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
7276

7377
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
7478
ARCH := $(shell uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')

0 commit comments

Comments
 (0)