Skip to content

Commit edc7627

Browse files
committed
helm: support ignore-not-found in undeploy targets
1 parent c7f6cde commit edc7627

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

  • internal/plugins/helm/v1/scaffolds/internal/templates
  • testdata/helm/memcached-operator

internal/plugins/helm/v1/scaffolds/internal/templates/makefile.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,22 +121,26 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
121121
122122
##@ Deployment
123123
124+
ifndef ignore-not-found
125+
ignore-not-found = false
126+
endif
127+
124128
.PHONY: install
125129
install: kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
126130
$(KUSTOMIZE) build config/crd | kubectl apply -f -
127131
128132
.PHONY: uninstall
129-
uninstall: kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
130-
$(KUSTOMIZE) build config/crd | kubectl delete -f -
133+
uninstall: kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
134+
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
131135
132136
.PHONY: deploy
133137
deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
134138
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
135139
$(KUSTOMIZE) build config/default | kubectl apply -f -
136140
137141
.PHONY: undeploy
138-
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
139-
$(KUSTOMIZE) build config/default | kubectl delete -f -
142+
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
143+
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
140144
141145
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
142146
ARCH := $(shell uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')

testdata/helm/memcached-operator/Makefile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,26 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
106106

107107
##@ Deployment
108108

109+
ifndef ignore-not-found
110+
ignore-not-found = false
111+
endif
112+
109113
.PHONY: install
110114
install: kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
111115
$(KUSTOMIZE) build config/crd | kubectl apply -f -
112116

113117
.PHONY: uninstall
114-
uninstall: kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
115-
$(KUSTOMIZE) build config/crd | kubectl delete -f -
118+
uninstall: kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
119+
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
116120

117121
.PHONY: deploy
118122
deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
119123
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
120124
$(KUSTOMIZE) build config/default | kubectl apply -f -
121125

122126
.PHONY: undeploy
123-
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
124-
$(KUSTOMIZE) build config/default | kubectl delete -f -
127+
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
128+
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
125129

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

0 commit comments

Comments
 (0)