@@ -153,6 +153,9 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
153
153
# Commenting out default which overwrites scoped config/rbac/role.yaml
154
154
# GOFLAGS="-mod=mod" $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
155
155
GOFLAGS=" -mod=mod" $(CONTROLLER_GEN ) $(CRD_OPTIONS ) webhook paths=" ./..." output:crd:artifacts:config=config/crd/bases
156
+ # run make nullables to generate nullable fields after all manifest changesin dependent targets.
157
+ # It's not included here because `test` and `bundle` target have different yaml styes.
158
+ # To keep dpa CRD the same, nullables have been added to test and bundle target separately.
156
159
157
160
generate : controller-gen # # Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
158
161
GOFLAGS=" -mod=mod" $(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate.go.txt" paths=" ./..."
@@ -163,7 +166,7 @@ fmt: ## Run go fmt against code.
163
166
vet : # # Run go vet against code.
164
167
go vet -mod=mod ./...
165
168
166
- test : manifests generate fmt vet envtest # # Run tests.
169
+ test : manifests nullables generate fmt vet envtest # # Run tests.
167
170
KUBEBUILDER_ASSETS=" $( ENVTESTPATH) " go test -mod=mod ./controllers/... ./pkg/... -coverprofile cover.out
168
171
169
172
@@ -290,48 +293,62 @@ rm -rf $$TMP_DIR ;\
290
293
}
291
294
endef
292
295
293
- $(GOBIN ) /yq :
294
- go install github.com/mikefarah/yq/v4@latest
296
+ YQ = $(shell pwd) /bin/yq
297
+ yq : # # Download yq locally if necessary.
298
+ # 4.28.1 is latest with go 1.17 go.mod
299
+ $(call go-install-tool,$(YQ ) ,github.com/mikefarah/yq/[email protected] )
300
+
301
+ OPERATOR_SDK = $(shell pwd) /bin/operator-sdk
302
+ operator-sdk :
303
+ # Download operator-sdk locally if does not exist
304
+ if [ ! -f $( OPERATOR_SDK) ]; then \
305
+ curl -Lo $(OPERATOR_SDK ) https://github.com/operator-framework/operator-sdk/releases/download/v1.23.0/operator-sdk_$(shell go env GOOS) _$(shell go env GOARCH) ; \
306
+ chmod +x $(OPERATOR_SDK ) ; \
307
+ fi
295
308
296
309
.PHONY : bundle
297
- bundle : manifests kustomize # # Generate bundle manifests and metadata, then validate generated files.
298
- operator-sdk generate kustomize manifests -q
310
+ bundle : manifests kustomize operator-sdk # # Generate bundle manifests and metadata, then validate generated files.
311
+ $( OPERATOR_SDK ) generate kustomize manifests -q
299
312
cd config/manager && $(KUSTOMIZE ) edit set image controller=$(IMG )
300
- $(KUSTOMIZE ) build config/manifests | operator-sdk generate bundle -q --extra-service-accounts " velero" --overwrite --version $(VERSION ) $(BUNDLE_METADATA_OPTS )
301
- @make nullable-crds-bundle nullable-crds-config # patch nullables in CRDs
313
+ $(KUSTOMIZE ) build config/manifests | $( OPERATOR_SDK ) generate bundle -q --extra-service-accounts " velero" --overwrite --version $(VERSION ) $(BUNDLE_METADATA_OPTS )
314
+ @make nullables
302
315
# Copy updated bundle.Dockerfile to CI's Dockerfile.bundle
303
316
# TODO: update CI to use generated one
304
317
cp bundle.Dockerfile build/Dockerfile.bundle
305
- operator-sdk bundle validate ./bundle
318
+ $(OPERATOR_SDK ) bundle validate ./bundle
319
+
320
+ .PHONY : nullables
321
+ nullables :
322
+ @make nullable-crds-bundle nullable-crds-config # patch nullables in CRDs
306
323
307
324
.PHONY : nullable-crds-bundle
308
325
nullable-crds-bundle : DPA_SPEC_CONFIG_PROP = .spec.versions.0.schema.openAPIV3Schema.properties.spec.properties.configuration.properties
309
326
nullable-crds-bundle : PROP_RESOURCE_ALLOC = properties.podConfig.properties.resourceAllocations
310
327
nullable-crds-bundle : VELERO_RESOURCE_ALLOC = $(DPA_SPEC_CONFIG_PROP ) .velero.$(PROP_RESOURCE_ALLOC )
311
328
nullable-crds-bundle : RESTIC_RESOURCE_ALLOC = $(DPA_SPEC_CONFIG_PROP ) .restic.$(PROP_RESOURCE_ALLOC )
312
329
nullable-crds-bundle : DPA_CRD_YAML ?= bundle/manifests/oadp.openshift.io_dataprotectionapplications.yaml
313
- nullable-crds-bundle : $( GOBIN ) / yq
330
+ nullable-crds-bundle : yq
314
331
# Velero CRD
315
- @$(GOBIN)/yq '$(VELERO_RESOURCE_ALLOC).nullable = true' $(DPA_CRD_YAML) > $(DPA_CRD_YAML).yqresult
332
+ @$(YQ) '$(VELERO_RESOURCE_ALLOC).nullable = true' $(DPA_CRD_YAML) > $(DPA_CRD_YAML).yqresult
316
333
@mv $(DPA_CRD_YAML).yqresult $(DPA_CRD_YAML)
317
- @$(GOBIN)/yq '$(VELERO_RESOURCE_ALLOC).properties.limits.nullable = true' $(DPA_CRD_YAML) > $(DPA_CRD_YAML).yqresult
334
+ @$(YQ) '$(VELERO_RESOURCE_ALLOC).properties.limits.nullable = true' $(DPA_CRD_YAML) > $(DPA_CRD_YAML).yqresult
318
335
@mv $(DPA_CRD_YAML).yqresult $(DPA_CRD_YAML)
319
- @$(GOBIN)/yq '$(VELERO_RESOURCE_ALLOC).properties.limits.additionalProperties.nullable = true' $(DPA_CRD_YAML) > $(DPA_CRD_YAML).yqresult
336
+ @$(YQ) '$(VELERO_RESOURCE_ALLOC).properties.limits.additionalProperties.nullable = true' $(DPA_CRD_YAML) > $(DPA_CRD_YAML).yqresult
320
337
@mv $(DPA_CRD_YAML).yqresult $(DPA_CRD_YAML)
321
- @$(GOBIN)/yq '$(VELERO_RESOURCE_ALLOC).properties.requests.nullable = true' $(DPA_CRD_YAML) > $(DPA_CRD_YAML).yqresult
338
+ @$(YQ) '$(VELERO_RESOURCE_ALLOC).properties.requests.nullable = true' $(DPA_CRD_YAML) > $(DPA_CRD_YAML).yqresult
322
339
@mv $(DPA_CRD_YAML).yqresult $(DPA_CRD_YAML)
323
- @$(GOBIN)/yq '$(VELERO_RESOURCE_ALLOC).properties.requests.additionalProperties.nullable = true' $(DPA_CRD_YAML) > $(DPA_CRD_YAML).yqresult
340
+ @$(YQ) '$(VELERO_RESOURCE_ALLOC).properties.requests.additionalProperties.nullable = true' $(DPA_CRD_YAML) > $(DPA_CRD_YAML).yqresult
324
341
@mv $(DPA_CRD_YAML).yqresult $(DPA_CRD_YAML)
325
342
# Restic CRD
326
- @$(GOBIN)/yq '$(RESTIC_RESOURCE_ALLOC).nullable = true' $(DPA_CRD_YAML) > $(DPA_CRD_YAML).yqresult
343
+ @$(YQ) '$(RESTIC_RESOURCE_ALLOC).nullable = true' $(DPA_CRD_YAML) > $(DPA_CRD_YAML).yqresult
327
344
@mv $(DPA_CRD_YAML).yqresult $(DPA_CRD_YAML)
328
- @$(GOBIN)/yq '$(RESTIC_RESOURCE_ALLOC).properties.limits.nullable = true' $(DPA_CRD_YAML) > $(DPA_CRD_YAML).yqresult
345
+ @$(YQ) '$(RESTIC_RESOURCE_ALLOC).properties.limits.nullable = true' $(DPA_CRD_YAML) > $(DPA_CRD_YAML).yqresult
329
346
@mv $(DPA_CRD_YAML).yqresult $(DPA_CRD_YAML)
330
- @$(GOBIN)/yq '$(RESTIC_RESOURCE_ALLOC).properties.limits.additionalProperties.nullable = true' $(DPA_CRD_YAML) > $(DPA_CRD_YAML).yqresult
347
+ @$(YQ) '$(RESTIC_RESOURCE_ALLOC).properties.limits.additionalProperties.nullable = true' $(DPA_CRD_YAML) > $(DPA_CRD_YAML).yqresult
331
348
@mv $(DPA_CRD_YAML).yqresult $(DPA_CRD_YAML)
332
- @$(GOBIN)/yq '$(RESTIC_RESOURCE_ALLOC).properties.requests.nullable = true' $(DPA_CRD_YAML) > $(DPA_CRD_YAML).yqresult
349
+ @$(YQ) '$(RESTIC_RESOURCE_ALLOC).properties.requests.nullable = true' $(DPA_CRD_YAML) > $(DPA_CRD_YAML).yqresult
333
350
@mv $(DPA_CRD_YAML).yqresult $(DPA_CRD_YAML)
334
- @$(GOBIN)/yq '$(RESTIC_RESOURCE_ALLOC).properties.requests.additionalProperties.nullable = true' $(DPA_CRD_YAML) > $(DPA_CRD_YAML).yqresult
351
+ @$(YQ) '$(RESTIC_RESOURCE_ALLOC).properties.requests.additionalProperties.nullable = true' $(DPA_CRD_YAML) > $(DPA_CRD_YAML).yqresult
335
352
@mv $(DPA_CRD_YAML).yqresult $(DPA_CRD_YAML)
336
353
337
354
.PHONY : nullable-crds-config
@@ -353,17 +370,17 @@ GIT_REV:=$(shell git rev-parse --short HEAD)
353
370
deploy-olm : THIS_OPERATOR_IMAGE?=ttl.sh/oadp-operator-$(GIT_REV ) :1h # Set target specific variable
354
371
deploy-olm : THIS_BUNDLE_IMAGE?=ttl.sh/oadp-operator-bundle-$(GIT_REV ) :1h # Set target specific variable
355
372
deploy-olm : DEPLOY_TMP:=$(shell mktemp -d) / # Set target specific variable
356
- deploy-olm :
373
+ deploy-olm : operator-sdk # # Build current branch operator image, bundle image, push and install via OLM
357
374
oc whoami # Check if logged in
358
375
oc create namespace $(OADP_TEST_NAMESPACE ) # This should error out if namespace already exists, delete namespace (to clear current resources) before proceeding
359
376
@echo " DEPLOY_TMP: $( DEPLOY_TMP) "
360
377
# build and push operator and bundle image
361
- # use operator-sdk to install bundle to authenticated cluster
378
+ # use $(OPERATOR_SDK) to install bundle to authenticated cluster
362
379
cp -r . $(DEPLOY_TMP ) && cd $(DEPLOY_TMP ) && \
363
380
IMG=$(THIS_OPERATOR_IMAGE ) BUNDLE_IMG=$(THIS_BUNDLE_IMAGE ) \
364
381
make docker-build docker-push bundle bundle-build bundle-push; \
365
382
rm -rf $(DEPLOY_TMP )
366
- operator-sdk run bundle $(THIS_BUNDLE_IMAGE ) --namespace $(OADP_TEST_NAMESPACE )
383
+ $( OPERATOR_SDK ) run bundle $(THIS_BUNDLE_IMAGE ) --namespace $(OADP_TEST_NAMESPACE )
367
384
368
385
.PHONY : opm
369
386
OPM = ./bin/opm
0 commit comments