Skip to content

Commit 6366640

Browse files
committed
scripts: add ignore-not-found for undeploy to Makefile boiler plate
This avoid undeploy failure if for some reason one of the kustomized resource is missing. Part of 5195 Signed-off-by: Samuel Gaist <samuel.gaist@idiap.ch>
1 parent 819984d commit 6366640

3 files changed

Lines changed: 50 additions & 4 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# entries is a list of entries to include in
2+
# release notes and/or the migration guide
3+
entries:
4+
- description: >
5+
The make uninstall and undeploy command from the generated Makefile
6+
now properly handle missing kustomized resources.
7+
8+
# kind is one of:
9+
# - addition
10+
# - change
11+
# - deprecation
12+
# - removal
13+
# - bugfix
14+
kind: "bugfix"
15+
16+
# Is this a breaking change?
17+
breaking: false
18+
19+
# NOTE: ONLY USE `pull_request_override` WHEN ADDING THIS
20+
# FILE FOR A PREVIOUSLY MERGED PULL_REQUEST!
21+
#
22+
# The generator auto-detects the PR number from the commit
23+
# message in which this file was originally added.
24+
#
25+
# What is the pull request number (without the "#")?
26+
# pull_request_override: 0
27+
28+
29+
# Migration can be defined to automatically add a section to
30+
# the migration guide. This is required for breaking changes.
31+
# migration:
32+
# header: Header text for the migration section
33+
# body: |
34+
# Body of the migration section. This should be formatted as markdown and can
35+
# span multiple lines.
36+
#
37+
# Using the YAML string '|' operator means that newlines in this string will
38+
# be honored and interpretted as newlines in the rendered markdown.

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,17 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
118118
119119
##@ Deployment
120120
121+
ifndef ignore-not-found
122+
ignore-not-found = false
123+
endif
124+
121125
.PHONY: install
122126
install: kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
123127
$(KUSTOMIZE) build config/crd | kubectl apply -f -
124128
125129
.PHONY: uninstall
126130
uninstall: kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
127-
$(KUSTOMIZE) build config/crd | kubectl delete -f -
131+
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
128132
129133
.PHONY: deploy
130134
deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
@@ -133,7 +137,7 @@ deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/c
133137
134138
.PHONY: undeploy
135139
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
136-
$(KUSTOMIZE) build config/default | kubectl delete -f -
140+
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
137141
138142
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
139143
ARCH := $(shell uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')

testdata/helm/memcached-operator/Makefile

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

104104
##@ Deployment
105105

106+
ifndef ignore-not-found
107+
ignore-not-found = false
108+
endif
109+
106110
.PHONY: install
107111
install: kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
108112
$(KUSTOMIZE) build config/crd | kubectl apply -f -
109113

110114
.PHONY: uninstall
111115
uninstall: kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
112-
$(KUSTOMIZE) build config/crd | kubectl delete -f -
116+
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
113117

114118
.PHONY: deploy
115119
deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
@@ -118,7 +122,7 @@ deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/c
118122

119123
.PHONY: undeploy
120124
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
121-
$(KUSTOMIZE) build config/default | kubectl delete -f -
125+
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
122126

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

0 commit comments

Comments
 (0)