Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix policy controller dependency #378

Merged
merged 5 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/build-images-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
58 changes: 41 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ resources:
- ../crd
- ../rbac
- ../manager
- ../policy-controller
- ../dependencies/policy-controller
13 changes: 13 additions & 0 deletions config/dependencies/policy-controller/kustomization.template.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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: |-
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
resources:
- github.com/Kuadrant/multicluster-gateway-controller/config/samples?ref=${POLICY_CONTROLLER_GITREF}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
resources:
- github.com/Kuadrant/multicluster-gateway-controller/config/samples?ref=main
1 change: 0 additions & 1 deletion config/manifests/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions config/samples/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ resources:
- kuadrant_v1beta1_kuadrant.yaml
- kuadrant_v1beta2_authpolicy.yaml
- kuadrant_v1beta2_ratelimitpolicy.yaml
- ../dependencies/policy-controller/samples
#+kubebuilder:scaffold:manifestskustomizesamples
Loading