From f7ff132a2e89146364098acc9e0b2e9c315d326a Mon Sep 17 00:00:00 2001 From: Brandon Ewing Date: Thu, 14 Jul 2022 14:38:09 -0500 Subject: [PATCH] fix helm-chart Makefile issue GNU make resolves the $(wildcard ) macro when starting a block, and caches it for the duration of the run. In order to correctly remove namespace references from the generated helm charts, we have to split the generation and editing into two makefile targets. --- Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b3a95380..ceabc97a 100644 --- a/Makefile +++ b/Makefile @@ -269,7 +269,10 @@ charts: mkdir -p $@ .PHONY: helm-chart -helm-chart: kustomize helm kubectl-slice yq charts +helm-chart: helm-chart-generate helm-chart-slice + +.PHONY: helm-chart-generate +helm-chart-generate: kustomize helm kubectl-slice yq charts @echo "== KUSTOMIZE (image and namespace) ==" cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} @@ -292,6 +295,10 @@ helm-chart: kustomize helm kubectl-slice yq charts --output-dir=charts/$(CHART_NAME)/templates \ --sort-by-kind @echo "AWX Operator installed with Helm Chart version $(VERSION)" > charts/$(CHART_NAME)/templates/NOTES.txt + +.PHONY: helm-chart-edit +helm-chart-slice: + @echo "== EDIT ==" $(foreach file, $(wildcard charts/$(CHART_NAME)/templates/*),$(YQ) -i 'del(.. | select(has("namespace")).namespace)' $(file);) $(foreach file, $(wildcard charts/$(CHART_NAME)/templates/*rolebinding*),$(YQ) -i '.subjects[0].namespace = "{{ .Release.Namespace }}"' $(file);) rm -f charts/$(CHART_NAME)/templates/namespace*.yaml