diff --git a/.github/workflows/build-images-base.yaml b/.github/workflows/build-images-base.yaml index c39ee77fe..dc2637fd2 100644 --- a/.github/workflows/build-images-base.yaml +++ b/.github/workflows/build-images-base.yaml @@ -19,6 +19,10 @@ on: description: Limitador Operator bundle version default: latest type: string + policyControllerVersion: + description: Policy Controller version + default: latest + type: string wasmShimVersion: description: WASM Shim version default: latest @@ -49,6 +53,10 @@ on: description: Limitador Operator bundle version default: latest type: string + policyControllerVersion: + description: Policy Controller version + default: latest + type: string wasmShimVersion: description: WASM Shim version default: latest @@ -127,6 +135,7 @@ jobs: AUTHORINO_OPERATOR_VERSION=${{ inputs.authorinoOperatorVersion }} \ LIMITADOR_OPERATOR_VERSION=${{ inputs.limitadorOperatorVersion }} \ WASM_SHIM_VERSION=${{ inputs.wasmShimVersion }} \ + POLICY_CONTROLLER_VERSION=${{ inputs.policyControllerVersion }} \ REPLACES_VERSION=${{ inputs.replacesVersion }} \ CHANNELS=${{ inputs.channels }} - name: Build Image @@ -170,6 +179,7 @@ jobs: AUTHORINO_OPERATOR_VERSION=${{ inputs.authorinoOperatorVersion }} \ LIMITADOR_OPERATOR_VERSION=${{ inputs.limitadorOperatorVersion }} \ WASM_SHIM_VERSION=${{ inputs.wasmShimVersion }} \ + POLICY_CONTROLLER_VERSION=${{ inputs.policyControllerVersion }} \ REPLACES_VERSION=${{ inputs.replacesVersion }} \ CHANNELS=${{ inputs.channels }} - name: Install qemu dependency diff --git a/Makefile b/Makefile index c97477d33..cb7842406 100644 --- a/Makefile +++ b/Makefile @@ -137,6 +137,18 @@ LIMITADOR_OPERATOR_GITREF = $(LIMITADOR_OPERATOR_BUNDLE_VERSION) endif LIMITADOR_OPERATOR_BUNDLE_IMG ?= quay.io/kuadrant/limitador-operator-bundle:$(LIMITADOR_OPERATOR_BUNDLE_IMG_TAG) +## policy-controller +POLICY_CONTROLLER_VERSION ?= latest +policy_controller_is_semantic := $(call is_semantic_version,$(POLICY_CONTROLLER_VERSION)) +ifeq (latest,$(POLICY_CONTROLLER_VERSION)) +POLICY_CONTROLLER_VERSION = 0.0.0 +POLICY_CONTROLLER_GITREF = main +else ifeq (true,$(policy_controller_is_semantic)) +POLICY_CONTROLLER_GITREF = v$(POLICY_CONTROLLER_VERSION) +else +POLICY_CONTROLLER_GITREF = $(POLICY_CONTROLLER_VERSION) +endif + ## wasm-shim WASM_SHIM_VERSION ?= latest shim_version_is_semantic := $(call is_semantic_version,$(WASM_SHIM_VERSION)) @@ -227,6 +239,21 @@ $(ACT): act: $(ACT) ## Download act locally if necessary. ##@ Development +define patch-config + envsubst \ + < $1 \ + > $2 +endef + +define update-csv-config + V="$1" \ + $(YQ) eval '$(3) = strenv(V)' -i $2 +endef + +define update-operator-dependencies + V=`$(PROJECT_PATH)/utils/parse-bundle-version.sh $(OPM) $(YQ) $2` \ + $(YQ) eval '(.dependencies[] | select(.value.packageName == "$1").value.version) = strenv(V)' -i bundle/metadata/dependencies.yaml +endef .PHONY: manifests manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. @@ -236,13 +263,12 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust .PHONY: dependencies-manifests dependencies-manifests: export AUTHORINO_OPERATOR_GITREF := $(AUTHORINO_OPERATOR_GITREF) dependencies-manifests: export LIMITADOR_OPERATOR_GITREF := $(LIMITADOR_OPERATOR_GITREF) +dependencies-manifests: export POLICY_CONTROLLER_GITREF := $(POLICY_CONTROLLER_GITREF) dependencies-manifests: ## Update kuadrant dependencies manifests. - envsubst \ - < config/dependencies/authorino/kustomization.template.yaml \ - > config/dependencies/authorino/kustomization.yaml - envsubst \ - < config/dependencies/limitador/kustomization.template.yaml \ - > config/dependencies/limitador/kustomization.yaml + $(call patch-config,config/dependencies/authorino/kustomization.template.yaml,config/dependencies/authorino/kustomization.yaml) + $(call patch-config,config/dependencies/limitador/kustomization.template.yaml,config/dependencies/limitador/kustomization.yaml) + $(call patch-config,config/dependencies/policy-controller/kustomization.template.yaml,config/dependencies/policy-controller/kustomization.yaml) + $(call patch-config,config/dependencies/policy-controller/samples/kustomization.template.yaml,config/dependencies/policy-controller/samples/kustomization.yaml) .PHONY: generate generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. @@ -421,25 +447,23 @@ rm -rf $$TMP_DIR ;\ endef .PHONY: bundle -bundle: $(OPM) $(YQ) manifests kustomize operator-sdk ## Generate bundle manifests and metadata, then validate generated files. +bundle: $(OPM) $(YQ) manifests dependencies-manifests kustomize operator-sdk ## Generate bundle manifests and metadata, then validate generated files. $(OPERATOR_SDK) generate kustomize manifests -q # Set desired operator image and related wasm shim image - V="$(RELATED_IMAGE_WASMSHIM)" $(YQ) eval '(select(.kind == "Deployment").spec.template.spec.containers[].env[] | select(.name == "RELATED_IMAGE_WASMSHIM").value) = strenv(V)' -i config/manager/manager.yaml + V="$(RELATED_IMAGE_WASMSHIM)" \ + $(YQ) eval '(select(.kind == "Deployment").spec.template.spec.containers[].env[] | select(.name == "RELATED_IMAGE_WASMSHIM").value) = strenv(V)' -i config/manager/manager.yaml cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG) # Update CSV - V="kuadrant-operator.v$(BUNDLE_VERSION)" $(YQ) eval '.metadata.name = strenv(V)' -i config/manifests/bases/kuadrant-operator.clusterserviceversion.yaml - V="$(BUNDLE_VERSION)" $(YQ) eval '.spec.version = strenv(V)' -i config/manifests/bases/kuadrant-operator.clusterserviceversion.yaml - V="$(IMG)" $(YQ) eval '.metadata.annotations.containerImage = strenv(V)' -i config/manifests/bases/kuadrant-operator.clusterserviceversion.yaml - V="kuadrant-operator.v$(REPLACES_VERSION)" $(YQ) eval '.spec.replaces = strenv(V)' -i config/manifests/bases/kuadrant-operator.clusterserviceversion.yaml + $(call update-csv-config,kuadrant-operator.v$(BUNDLE_VERSION),config/manifests/bases/kuadrant-operator.clusterserviceversion.yaml,.metadata.name) + $(call update-csv-config,$(BUNDLE_VERSION),config/manifests/bases/kuadrant-operator.clusterserviceversion.yaml,.spec.version) + $(call update-csv-config,$(IMG),config/manifests/bases/kuadrant-operator.clusterserviceversion.yaml,.metadata.annotations.containerImage) + $(call update-csv-config,kuadrant-operator.v$(REPLACES_VERSION),config/manifests/bases/kuadrant-operator.clusterserviceversion.yaml,.spec.replaces) # Generate bundle $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version $(BUNDLE_VERSION) $(BUNDLE_METADATA_OPTS) # Update operator dependencies # TODO(eguzki): run only if not default one. Avoid bundle parsing if version is known in advance - V=`$(PROJECT_PATH)/utils/parse-bundle-version.sh $(OPM) $(YQ) $(LIMITADOR_OPERATOR_BUNDLE_IMG)` \ - $(YQ) eval '(.dependencies[] | select(.value.packageName == "limitador-operator").value.version) = strenv(V)' -i bundle/metadata/dependencies.yaml - V=`$(PROJECT_PATH)/utils/parse-bundle-version.sh $(OPM) $(YQ) $(AUTHORINO_OPERATOR_BUNDLE_IMG)` \ - $(YQ) eval '(.dependencies[] | select(.value.packageName == "authorino-operator").value.version) = strenv(V)' -i bundle/metadata/dependencies.yaml - # Validate bundle manifests + $(call update-operator-dependencies,limitador-operator,$(LIMITADOR_OPERATOR_BUNDLE_IMG)) + $(call update-operator-dependencies,authorino-operator,$(AUTHORINO_OPERATOR_BUNDLE_IMG)) $(OPERATOR_SDK) bundle validate ./bundle $(MAKE) bundle-ignore-createdAt diff --git a/config/default/kustomization.yaml b/config/default/kustomization.yaml index 6c23d3a29..f4f521558 100644 --- a/config/default/kustomization.yaml +++ b/config/default/kustomization.yaml @@ -49,4 +49,4 @@ resources: - ../crd - ../rbac - ../manager -- ../policy-controller +- ../dependencies/policy-controller diff --git a/config/policy-controller/delete-ns.yaml b/config/dependencies/policy-controller/delete-ns.yaml similarity index 100% rename from config/policy-controller/delete-ns.yaml rename to config/dependencies/policy-controller/delete-ns.yaml diff --git a/config/dependencies/policy-controller/kustomization.template.yaml b/config/dependencies/policy-controller/kustomization.template.yaml new file mode 100644 index 000000000..1d9e62f85 --- /dev/null +++ b/config/dependencies/policy-controller/kustomization.template.yaml @@ -0,0 +1,13 @@ +resources: +- github.com/Kuadrant/multicluster-gateway-controller/config/policy-controller/default?ref=${POLICY_CONTROLLER_GITREF} + +patchesStrategicMerge: +- delete-ns.yaml + +patches: +- patch: |- + - op: add + path: /spec/template/spec/containers/0/args/- + value: --ocm-hub=false + target: + kind: Deployment diff --git a/config/policy-controller/kustomization.yaml b/config/dependencies/policy-controller/kustomization.yaml similarity index 93% rename from config/policy-controller/kustomization.yaml rename to config/dependencies/policy-controller/kustomization.yaml index 44eeee272..60eb380c6 100644 --- a/config/policy-controller/kustomization.yaml +++ b/config/dependencies/policy-controller/kustomization.yaml @@ -2,7 +2,7 @@ resources: - github.com/Kuadrant/multicluster-gateway-controller/config/policy-controller/default?ref=main patchesStrategicMerge: - - delete-ns.yaml +- delete-ns.yaml patches: - patch: |- diff --git a/config/dependencies/policy-controller/samples/kustomization.template.yaml b/config/dependencies/policy-controller/samples/kustomization.template.yaml new file mode 100644 index 000000000..6af47e717 --- /dev/null +++ b/config/dependencies/policy-controller/samples/kustomization.template.yaml @@ -0,0 +1,2 @@ +resources: +- github.com/Kuadrant/multicluster-gateway-controller/config/samples?ref=${POLICY_CONTROLLER_GITREF} diff --git a/config/dependencies/policy-controller/samples/kustomization.yaml b/config/dependencies/policy-controller/samples/kustomization.yaml new file mode 100644 index 000000000..d02877fc8 --- /dev/null +++ b/config/dependencies/policy-controller/samples/kustomization.yaml @@ -0,0 +1,2 @@ +resources: +- github.com/Kuadrant/multicluster-gateway-controller/config/samples?ref=main diff --git a/config/manifests/kustomization.yaml b/config/manifests/kustomization.yaml index 82148c68f..9356eeda7 100644 --- a/config/manifests/kustomization.yaml +++ b/config/manifests/kustomization.yaml @@ -4,7 +4,6 @@ resources: - bases/kuadrant-operator.clusterserviceversion.yaml - ../default - ../samples -- github.com/Kuadrant/multicluster-gateway-controller/config/samples - ../scorecard # [WEBHOOK] To enable webhooks, uncomment all the sections with [WEBHOOK] prefix. diff --git a/config/samples/kustomization.yaml b/config/samples/kustomization.yaml index 5202a04c9..3a0b01be5 100644 --- a/config/samples/kustomization.yaml +++ b/config/samples/kustomization.yaml @@ -3,4 +3,5 @@ resources: - kuadrant_v1beta1_kuadrant.yaml - kuadrant_v1beta2_authpolicy.yaml - kuadrant_v1beta2_ratelimitpolicy.yaml +- ../dependencies/policy-controller/samples #+kubebuilder:scaffold:manifestskustomizesamples