@@ -290,22 +290,55 @@ rm -rf $$TMP_DIR ;\
290
290
}
291
291
endef
292
292
293
- yq :
293
+ $( GOBIN ) / yq :
294
294
go install github.com/mikefarah/yq/v4@latest
295
295
296
296
.PHONY : bundle
297
- bundle : manifests kustomize yq # # Generate bundle manifests and metadata, then validate generated files.
297
+ bundle : manifests kustomize # # Generate bundle manifests and metadata, then validate generated files.
298
298
operator-sdk generate kustomize manifests -q
299
299
cd config/manager && $(KUSTOMIZE ) edit set image controller=$(IMG )
300
- $(KUSTOMIZE ) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION ) $(BUNDLE_METADATA_OPTS )
301
- # Removes placeholder velero deployment used so `operator-sdk generate bundle` adds velero service account and role to bundle CSV using yq. See https://github.com/mikefarah/yq/#install
302
- $(GOBIN ) /yq eval ' del(.spec.install.spec.deployments.1)' bundle/manifests/oadp-operator.clusterserviceversion.yaml > bundle/manifests/oadp-operator.clusterserviceversion.yaml.yqresult
303
- mv bundle/manifests/oadp-operator.clusterserviceversion.yaml.yqresult bundle/manifests/oadp-operator.clusterserviceversion.yaml
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
304
302
# Copy updated bundle.Dockerfile to CI's Dockerfile.bundle
305
303
# TODO: update CI to use generated one
306
304
cp bundle.Dockerfile build/Dockerfile.bundle
307
305
operator-sdk bundle validate ./bundle
308
306
307
+ .PHONY : nullable-crds-bundle
308
+ nullable-crds-bundle : DPA_SPEC_CONFIG_PROP = .spec.versions.0.schema.openAPIV3Schema.properties.spec.properties.configuration.properties
309
+ nullable-crds-bundle : PROP_RESOURCE_ALLOC = properties.podConfig.properties.resourceAllocations
310
+ nullable-crds-bundle : VELERO_RESOURCE_ALLOC = $(DPA_SPEC_CONFIG_PROP ) .velero.$(PROP_RESOURCE_ALLOC )
311
+ nullable-crds-bundle : RESTIC_RESOURCE_ALLOC = $(DPA_SPEC_CONFIG_PROP ) .restic.$(PROP_RESOURCE_ALLOC )
312
+ nullable-crds-bundle : DPA_CRD_YAML ?= bundle/manifests/oadp.openshift.io_dataprotectionapplications.yaml
313
+ nullable-crds-bundle : $(GOBIN ) /yq
314
+ # Velero CRD
315
+ @$(GOBIN)/yq '$(VELERO_RESOURCE_ALLOC).nullable = true' $(DPA_CRD_YAML) > $(DPA_CRD_YAML).yqresult
316
+ @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
318
+ @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
320
+ @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
322
+ @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
324
+ @mv $(DPA_CRD_YAML).yqresult $(DPA_CRD_YAML)
325
+ # Restic CRD
326
+ @$(GOBIN)/yq '$(RESTIC_RESOURCE_ALLOC).nullable = true' $(DPA_CRD_YAML) > $(DPA_CRD_YAML).yqresult
327
+ @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
329
+ @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
331
+ @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
333
+ @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
335
+ @mv $(DPA_CRD_YAML).yqresult $(DPA_CRD_YAML)
336
+
337
+ .PHONY : nullable-crds-config
338
+ nullable-crds-config : DPA_CRD_YAML ?= config/crd/bases/oadp.openshift.io_dataprotectionapplications.yaml
339
+ nullable-crds-config :
340
+ DPA_CRD_YAML=$(DPA_CRD_YAML ) make nullable-crds-bundle
341
+
309
342
.PHONY : bundle-build
310
343
bundle-build : # # Build the bundle image.
311
344
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG ) . $(DOCKER_BUILD_ARGS )
0 commit comments