@@ -160,7 +160,9 @@ KUSTOMIZE_INPUT := $(shell [ ! -d deploy/kustomize ] || find deploy/kustomize -t
160
160
KUSTOMIZE :=
161
161
162
162
# Setting this to any non-empty value before "make kustomize" will enable
163
- # collection of coverage profiles in all deployments.
163
+ # collection of coverage profiles in all deployments. This also sets up the
164
+ # original deployment files under "deploy/nocoverage" for use as reference when
165
+ # testing the operator.
164
166
KUSTOMIZE_WITH_COVERAGE =
165
167
ifneq "$(KUSTOMIZE_WITH_COVERAGE ) " ""
166
168
KUSTOMIZE_COVERAGE_SUFFIX = -coverage
@@ -206,14 +208,22 @@ KUSTOMIZE_OUTPUT := $(foreach item,$(KUSTOMIZE),$(firstword $(subst =, ,$(item))
206
208
# right one.
207
209
KUSTOMIZE_LOOKUP_KUSTOMIZATION = $(strip $(foreach item,$(KUSTOMIZE ) ,$(if $(filter $(1 ) =% ,$(item ) ) ,$(word 2,$(subst =, ,$(item ) ) ) ) ) )
208
210
211
+ # This is a wrapper around KUSTOMIZE_LOOKUP_KUSTOMIZATION which
212
+ # removes the -coverage suffix.
213
+ KUSTOMIZE_LOOKUP_KUSTOMIZATION_NO_COVERAGE = $(subst -coverage,,$(call KUSTOMIZE_LOOKUP_KUSTOMIZATION,$(1 ) ) )
214
+
209
215
# This function takes the kustomize binary and the name of an output
210
216
# file as arguments and returns the command which produces that file
211
217
# as stdout.
212
- KUSTOMIZE_INVOCATION = (echo '\# Generated with "make kustomize", do not edit!'; echo; $(1) build --load-restrictor LoadRestrictionsNone $(call KUSTOMIZE_LOOKUP_KUSTOMIZATION ,$(2)))
218
+ KUSTOMIZE_INVOCATION = (echo '\# Generated with "make kustomize", do not edit!'; echo; $(1) build --load-restrictor LoadRestrictionsNone $(call $(3) ,$(2)))
213
219
214
220
$(KUSTOMIZE_OUTPUT ) : _work/kustomize $(KUSTOMIZE_INPUT )
215
221
mkdir -p ${@ D}
216
- $(call KUSTOMIZE_INVOCATION,$< ,$@ ) > $@
222
+ $(call KUSTOMIZE_INVOCATION,$< ,$@ ,KUSTOMIZE_LOOKUP_KUSTOMIZATION) > $@
223
+ ifneq "$(KUSTOMIZE_WITH_COVERAGE ) " ""
224
+ mkdir -p $(subst deploy/,deploy/nocoverage/,${@D})
225
+ $(call KUSTOMIZE_INVOCATION,$<,$@,KUSTOMIZE_LOOKUP_KUSTOMIZATION_NO_COVERAGE) >$(subst deploy/,deploy/nocoverage/,$@)
226
+ endif
217
227
if echo "$@" | grep '/pmem-csi-' | grep -qv '\-operator'; then \
218
228
dir=$$(echo "$@" | tr - / | sed -e 's;kubernetes/;kubernetes-;' -e 's;/alpha/;-alpha/;' -e 's;/distributed/;-distributed/;' -e 's/.yaml//' -e 's;/pmem/csi/;/;') && \
219
229
mkdir -p $$dir && \
@@ -222,9 +232,13 @@ $(KUSTOMIZE_OUTPUT): _work/kustomize $(KUSTOMIZE_INPUT)
222
232
fi
223
233
224
234
kustomize : clean_kustomize_output $(KUSTOMIZE_OUTPUT )
235
+ ifneq "$(KUSTOMIZE_WITH_COVERAGE ) " ""
236
+ sed -i -e 's/embed kubernetes-/embed nocoverage kubernetes-/' deploy/yamls.go
237
+ endif
225
238
226
239
clean_kustomize_output :
227
- rm -rf deploy/kubernetes-*
240
+ rm -rf deploy/kubernetes-* deploy/nocoverage
241
+ sed -i -e ' s/embed nocoverage /embed /' deploy/yamls.go
228
242
rm -f $(KUSTOMIZE_OUTPUT )
229
243
230
244
# Always re-generate the output files because "git rebase" might have
@@ -241,7 +255,7 @@ clean-kustomize:
241
255
test : test-kustomize
242
256
test-kustomize : $(addprefix test-kustomize-,$(KUSTOMIZE_OUTPUT ) )
243
257
$(addprefix test-kustomize-,$(KUSTOMIZE_OUTPUT ) ) : test-kustomize-% : _work/kustomize
244
- @ if ! diff <( $( call KUSTOMIZE_INVOCATION,$< ,$* ) ) $* ; then echo " $* was modified manually" && false ; fi
258
+ @ if ! diff <( $( call KUSTOMIZE_INVOCATION,$< ,$* ,KUSTOMIZE_LOOKUP_KUSTOMIZATION ) ) $* ; then echo " $* was modified manually" && false ; fi
245
259
246
260
# Targets in the makefile can depend on check-go-version-<path to go binary>
247
261
# to trigger a warning if the x.y version of that binary does not match
0 commit comments