From 8a789ed3d973d8ff10096287503e356c49abf8f5 Mon Sep 17 00:00:00 2001 From: Eguzki Astiz Lezaun Date: Thu, 8 Dec 2022 15:44:38 +0100 Subject: [PATCH] local operator catalog raw file based format (#107) * local operator catalog raw file based format * undo local testing setting * multiple subscriptions not needed, only one * Makefile refactor * doc/development.md: catalog doc * github actions for the catalog image * lint issues fixed * Update doc/development.md Co-authored-by: dd di cesare <4183971+didierofrivia@users.noreply.github.com> Co-authored-by: Alex Snaps Co-authored-by: dd di cesare <4183971+didierofrivia@users.noreply.github.com> --- .github/workflows/build-images.yaml | 20 +- .gitignore | 5 +- Makefile | 188 +++++++++--------- catalog/authorino-operator-channel-entry.yaml | 6 + catalog/kuadrant-operator-channel-entry.yaml | 6 + catalog/limitador-operator-channel-entry.yaml | 6 + config/deploy/olm/subscription.yaml | 3 +- ...erator.clusterserviceversion.template.yaml | 63 ------ ...adrant-operator.clusterserviceversion.yaml | 44 ++-- doc/development.md | 165 ++++++++++++++- make/act.mk | 4 - make/catalog.mk | 50 +++++ make/kind.mk | 4 - pkg/common/yaml_decoder.go | 3 +- utils/dependencies-template.yaml | 9 - utils/generate-catalog.sh | 83 ++++++++ utils/generate-dependencies-yaml.sh | 10 - utils/parse-bundle-version.sh | 9 + 18 files changed, 447 insertions(+), 231 deletions(-) create mode 100644 catalog/authorino-operator-channel-entry.yaml create mode 100644 catalog/kuadrant-operator-channel-entry.yaml create mode 100644 catalog/limitador-operator-channel-entry.yaml delete mode 100644 config/manifests/bases/kuadrant-operator.clusterserviceversion.template.yaml create mode 100644 make/catalog.mk delete mode 100755 utils/dependencies-template.yaml create mode 100755 utils/generate-catalog.sh delete mode 100755 utils/generate-dependencies-yaml.sh create mode 100755 utils/parse-bundle-version.sh diff --git a/.github/workflows/build-images.yaml b/.github/workflows/build-images.yaml index 1aefd2096..28da6e334 100644 --- a/.github/workflows/build-images.yaml +++ b/.github/workflows/build-images.yaml @@ -2,8 +2,8 @@ name: Build Images on: push: - branches: [ '*' ] - tags: [ '*' ] + branches: ['*'] + tags: ['*'] env: IMG_TAGS: ${{ github.ref_name }} @@ -69,9 +69,6 @@ jobs: - name: Run make bundle if: ${{ github.ref_name != env.MAIN_BRANCH_NAME }} run: make bundle REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} IMAGE_TAG=${{ github.ref_name }} - - name: Run make bundle (main) - if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }} - run: make bundle REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} IMAGE_TAG=latest VERSION=0.0.0 - name: Git diff run: git diff - name: Install qemu dependency @@ -117,14 +114,8 @@ jobs: id: add-latest-tag run: | echo "IMG_TAGS=latest ${{ env.IMG_TAGS }}" >> $GITHUB_ENV - - name: Run make catalog-generate - if: ${{ github.ref_name != env.MAIN_BRANCH_NAME }} - run: make catalog-generate REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} IMAGE_TAG=${{ github.ref_name }} - - name: Run make catalog-generate (main) - if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }} - run: make catalog-generate REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} IMAGE_TAG=latest VERSION=0.0.0 - - name: Git diff - run: git diff + - name: Generate Catalog Content + run: make catalog - name: Install qemu dependency run: | sudo apt-get update @@ -136,8 +127,9 @@ jobs: image: kuadrant-operator-catalog tags: ${{ env.IMG_TAGS }} platforms: linux/amd64,linux/arm64 + context: ./catalog dockerfiles: | - ./index.Dockerfile + ./catalog/kuadrant-operator-catalog.Dockerfile - name: Push Image if: ${{ !env.ACT }} id: push-to-quay diff --git a/.gitignore b/.gitignore index 2f8743cf6..780fb3c02 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,5 @@ testbin/* *~ kuadrant-operator -# ./bin/opm index add --generate output -database/index.db -index.Dockerfile +/catalog/kuadrant-operator-catalog +/catalog/kuadrant-operator-catalog.Dockerfile diff --git a/Makefile b/Makefile index ef66acbcc..7295cc700 100644 --- a/Makefile +++ b/Makefile @@ -78,14 +78,6 @@ SHELL = /usr/bin/env bash -o pipefail KUADRANT_NAMESPACE ?= kuadrant-system # Kuadrant component versions -## kuadrant controller -#ToDo Pin this version once we have an initial release of the controller -KUADRANT_CONTROLLER_VERSION ?= latest -ifeq (latest,$(KUADRANT_CONTROLLER_VERSION)) -KUADRANT_CONTROLLER_GITREF = main -else -KUADRANT_CONTROLLER_GITREF = $(KUADRANT_CONTROLLER_VERSION) -endif ## authorino #ToDo Pin this version once we have an initial release of authorino AUTHORINO_OPERATOR_VERSION ?= latest @@ -94,7 +86,7 @@ AUTHORINO_OPERATOR_BUNDLE_VERSION = 0.0.0 AUTHORINO_OPERATOR_BUNDLE_IMG_TAG = latest AUTHORINO_OPERATOR_GITREF = main else -AUTHORINO_OPERATOR_BUNDLE_VERSION = ${AUTHORINO_OPERATOR_VERSION} +AUTHORINO_OPERATOR_BUNDLE_VERSION = $(AUTHORINO_OPERATOR_VERSION) AUTHORINO_OPERATOR_BUNDLE_IMG_TAG = v$(AUTHORINO_OPERATOR_BUNDLE_VERSION) AUTHORINO_OPERATOR_GITREF = v$(AUTHORINO_OPERATOR_BUNDLE_VERSION) endif @@ -131,9 +123,69 @@ all: build help: ## Display this help. @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-30s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) +##@ Tools + +OPERATOR_SDK = $(PROJECT_PATH)/bin/operator-sdk +OPERATOR_SDK_VERSION = v1.22.0 +$(OPERATOR_SDK): + ./utils/install-operator-sdk.sh $(OPERATOR_SDK) $(OPERATOR_SDK_VERSION) + +.PHONY: operator-sdk +operator-sdk: $(OPERATOR_SDK) ## Download operator-sdk locally if necessary. + +CONTROLLER_GEN = $(PROJECT_PATH)/bin/controller-gen +$(CONTROLLER_GEN): + $(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.10.0) + +.PHONY: controller-gen +controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. + +KUSTOMIZE = $(PROJECT_PATH)/bin/kustomize +$(KUSTOMIZE): + $(call go-install-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v4@v4.5.5) + +.PHONY: kustomize +kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. + +YQ=$(PROJECT_PATH)/bin/yq +$(YQ): + $(call go-install-tool,$(YQ),github.com/mikefarah/yq/v4@latest) + +.PHONY: yq +yq: $(YQ) ## Download yq locally if necessary. + +OPM = $(PROJECT_PATH)/bin/opm +OPM_VERSION = v1.26.2 +$(OPM): + @{ \ + set -e ;\ + mkdir -p $(dir $(OPM)) ;\ + OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \ + curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/$(OPM_VERSION)/$${OS}-$${ARCH}-opm ;\ + chmod +x $(OPM) ;\ + } + +.PHONY: opm +opm: $(OPM) ## Download opm locally if necessary. + +KIND = $(PROJECT_PATH)/bin/kind +$(KIND): + $(call go-install-tool,$(KIND),sigs.k8s.io/kind@v0.11.1) + +.PHONY: kind +kind: $(KIND) ## Download kind locally if necessary. + +ACT = $(PROJECT_PATH)/bin/act +$(ACT): + $(call go-install-tool,$(ACT),github.com/nektos/act@latest) + +.PHONY: act +act: $(ACT) ## Download act locally if necessary. + ##@ Development -manifests: controller-gen dependencies-manifests ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. +.PHONY: manifests +manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. $(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases .PHONY: dependencies-manifests @@ -147,6 +199,7 @@ dependencies-manifests: ## Update kuadrant dependencies manifests. < config/dependencies/limitador/kustomization.template.yaml \ > config/dependencies/limitador/kustomization.yaml +.PHONY: generate generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." @@ -174,12 +227,11 @@ namespace: ## Creates a namespace where to deploy Kuadrant Operator kubectl create namespace $(KUADRANT_NAMESPACE) .PHONY: local-setup -local-setup: export IMG := $(IMAGE_TAG_BASE):dev -local-setup: ## Deploy locally kuadrant operator from the current code +local-setup: $(KIND) ## Deploy locally kuadrant operator from the current code $(MAKE) local-env-setup - $(MAKE) docker-build - $(KIND) load docker-image $(IMG) --name $(KIND_CLUSTER_NAME) - $(MAKE) deploy + $(MAKE) docker-build IMG=$(IMAGE_TAG_BASE):dev + $(KIND) load docker-image $(IMAGE_TAG_BASE):dev --name $(KIND_CLUSTER_NAME) + $(MAKE) deploy IMG=$(IMAGE_TAG_BASE):dev kubectl -n $(KUADRANT_NAMESPACE) wait --timeout=300s --for=condition=Available deployments --all @echo @echo "Now you can export the kuadrant gateway by doing:" @@ -225,10 +277,10 @@ run: generate fmt vet ## Run a controller from your host. go run ./main.go docker-build: ## Build docker image with the manager. - docker build -t ${IMG} . + docker build -t $(IMG) . docker-push: ## Push docker image with the manager. - docker push ${IMG} + docker push $(IMG) ##@ Deployment @@ -238,10 +290,10 @@ install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. $(KUSTOMIZE) build config/crd | kubectl delete -f - -deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. - cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} +deploy: manifests dependencies-manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. + cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG) $(KUSTOMIZE) build config/deploy | kubectl apply -f - - cd config/manager && $(KUSTOMIZE) edit set image controller=${IMAGE_TAG_BASE}:latest + cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMAGE_TAG_BASE):latest undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. $(KUSTOMIZE) build config/deploy | kubectl delete -f - @@ -251,34 +303,28 @@ deploy-dependencies: kustomize dependencies-manifests ## Deploy dependencies to kubectl -n "$(KUADRANT_NAMESPACE)" wait --timeout=300s --for=condition=Available deployments --all .PHONY: install-olm -install-olm: +install-olm: $(OPERATOR_SDK) $(OPERATOR_SDK) olm install .PHONY: uninstall-olm uninstall-olm: $(OPERATOR_SDK) olm uninstall -deploy-olm: ## Deploy controller to the K8s cluster specified in ~/.kube/config using OLM catalog image. +deploy-catalog: $(KUSTOMIZE) $(YQ) ## Deploy controller to the K8s cluster specified in ~/.kube/config using OLM catalog image. + V="$(CATALOG_IMG)" $(YQ) eval '.spec.image = strenv(V)' -i config/deploy/olm/catalogsource.yaml $(KUSTOMIZE) build config/deploy/olm | kubectl apply -f - -undeploy-olm: ## Undeploy controller from the K8s cluster specified in ~/.kube/config using OLM catalog image. +undeploy-catalog: $(KUSTOMIZE) ## Undeploy controller from the K8s cluster specified in ~/.kube/config using OLM catalog image. $(KUSTOMIZE) build config/deploy/olm | kubectl delete -f - -CONTROLLER_GEN = $(shell pwd)/bin/controller-gen -controller-gen: ## Download controller-gen locally if necessary. - $(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.10.0) - -KUSTOMIZE = $(shell pwd)/bin/kustomize -kustomize: ## Download kustomize locally if necessary. - $(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v4@v4.5.5) ENVTEST = $(shell pwd)/bin/setup-envtest envtest: ## Download envtest-setup locally if necessary. - $(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest) + $(call go-install-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest) -# go-get-tool will 'go install' any package $2 and install it to $1. +# go-install-tool will 'go install' any package $2 and install it to $1. PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) -define go-get-tool +define go-install-tool @[ -f $(1) ] || { \ set -e ;\ TMP_DIR=$$(mktemp -d) ;\ @@ -290,27 +336,24 @@ rm -rf $$TMP_DIR ;\ } endef -OPERATOR_SDK = $(shell pwd)/bin/operator-sdk -OPERATOR_SDK_VERSION = v1.22.0 -operator-sdk: ## Download operator-sdk locally if necessary. - ./utils/install-operator-sdk.sh $(OPERATOR_SDK) $(OPERATOR_SDK_VERSION) - -.PHONY: bundle-dependencies -bundle-dependencies: export AUTHORINO_OPERATOR_BUNDLE_VERSION := $(AUTHORINO_OPERATOR_BUNDLE_VERSION) -bundle-dependencies: export LIMITADOR_OPERATOR_BUNDLE_VERSION := $(LIMITADOR_OPERATOR_BUNDLE_VERSION) -bundle-dependencies: ## Generate bundle dependencies file. - ./utils/generate-dependencies-yaml.sh > bundle/metadata/dependencies.yaml - .PHONY: bundle -bundle: export IMAGE_TAG := $(IMAGE_TAG) -bundle: export BUNDLE_VERSION := $(VERSION) -bundle: manifests kustomize operator-sdk bundle-dependencies ## Generate bundle manifests and metadata, then validate generated files. +bundle: $(OPM) $(YQ) manifests kustomize operator-sdk ## Generate bundle manifests and metadata, then validate generated files. $(OPERATOR_SDK) generate kustomize manifests -q + # Set desired operator image cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG) - envsubst \ - < config/manifests/bases/kuadrant-operator.clusterserviceversion.template.yaml \ - > config/manifests/bases/kuadrant-operator.clusterserviceversion.yaml + # Update CSV + V="kuadrant-operator.v$(VERSION)" $(YQ) eval '.metadata.name = strenv(V)' -i config/manifests/bases/kuadrant-operator.clusterserviceversion.yaml + V="$(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 + # Generate bundle $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version $(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 $(OPERATOR_SDK) bundle validate ./bundle .PHONY: bundle-build @@ -321,51 +364,6 @@ bundle-build: ## Build the bundle image. bundle-push: ## Push the bundle image. $(MAKE) docker-push IMG=$(BUNDLE_IMG) -.PHONY: opm -OPM = ./bin/opm -opm: ## Download opm locally if necessary. -ifeq (,$(wildcard $(OPM))) -ifeq (,$(shell which opm 2>/dev/null)) - @{ \ - set -e ;\ - mkdir -p $(dir $(OPM)) ;\ - OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \ - curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.15.1/$${OS}-$${ARCH}-opm ;\ - chmod +x $(OPM) ;\ - } -else -OPM = $(shell which opm) -endif -endif - -# A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMGS=example.com/operator-bundle:v0.1.0,example.com/operator-bundle:v0.2.0). -# These images MUST exist in a registry and be pull-able. -BUNDLE_IMGS ?= $(BUNDLE_IMG),$(LIMITADOR_OPERATOR_BUNDLE_IMG),$(AUTHORINO_OPERATOR_BUNDLE_IMG) - -# The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0). -CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:$(IMAGE_TAG) - -# Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image. -ifneq ($(origin CATALOG_BASE_IMG), undefined) -FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG) -endif - -# Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'. -# This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see: -# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator -.PHONY: catalog-build -catalog-build: opm ## Build a catalog image. - $(OPM) index add --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT) - -.PHONY: catalog-generate -catalog-generate: opm ## Generate a catalog/index Dockerfile. - $(OPM) index add --generate --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT) - -# Push the catalog image. -.PHONY: catalog-push -catalog-push: ## Push a catalog image. - $(MAKE) docker-push IMG=$(CATALOG_IMG) - ##@ Code Style GOLANGCI-LINT = $(PROJECT_PATH)/bin/golangci-lint diff --git a/catalog/authorino-operator-channel-entry.yaml b/catalog/authorino-operator-channel-entry.yaml new file mode 100644 index 000000000..3da5ddc96 --- /dev/null +++ b/catalog/authorino-operator-channel-entry.yaml @@ -0,0 +1,6 @@ +--- +schema: olm.channel +package: authorino-operator +name: preview +entries: + - name: authorino-operator.v0.0.0 diff --git a/catalog/kuadrant-operator-channel-entry.yaml b/catalog/kuadrant-operator-channel-entry.yaml new file mode 100644 index 000000000..3e8824625 --- /dev/null +++ b/catalog/kuadrant-operator-channel-entry.yaml @@ -0,0 +1,6 @@ +--- +schema: olm.channel +package: kuadrant-operator +name: preview +entries: + - name: kuadrant-operator.v0.0.0 diff --git a/catalog/limitador-operator-channel-entry.yaml b/catalog/limitador-operator-channel-entry.yaml new file mode 100644 index 000000000..c47aae55a --- /dev/null +++ b/catalog/limitador-operator-channel-entry.yaml @@ -0,0 +1,6 @@ +--- +schema: olm.channel +package: limitador-operator +name: preview +entries: + - name: limitador-operator.v0.0.0 diff --git a/config/deploy/olm/subscription.yaml b/config/deploy/olm/subscription.yaml index 58a9456e7..106641ab1 100644 --- a/config/deploy/olm/subscription.yaml +++ b/config/deploy/olm/subscription.yaml @@ -1,3 +1,4 @@ +--- apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: @@ -6,4 +7,4 @@ spec: source: kuadrant-operator-catalog sourceNamespace: kuadrant-system name: kuadrant-operator - channel: "alpha" + channel: "preview" diff --git a/config/manifests/bases/kuadrant-operator.clusterserviceversion.template.yaml b/config/manifests/bases/kuadrant-operator.clusterserviceversion.template.yaml deleted file mode 100644 index c6680e4de..000000000 --- a/config/manifests/bases/kuadrant-operator.clusterserviceversion.template.yaml +++ /dev/null @@ -1,63 +0,0 @@ -apiVersion: operators.coreos.com/v1alpha1 -kind: ClusterServiceVersion -metadata: - annotations: - alm-examples: '[]' - capabilities: Basic Install - categories: Integration & Delivery - containerImage: quay.io/kuadrant/kuadrant-operator:${IMAGE_TAG} - operators.operatorframework.io/builder: operator-sdk-v1.9.0 - operators.operatorframework.io/project_layout: unknown - repository: https://github.com/Kuadrant/kuadrant-operator - support: kuadrant - name: kuadrant-operator.v${BUNDLE_VERSION} - namespace: placeholder -spec: - apiservicedefinitions: {} - customresourcedefinitions: - owned: - - description: Kuadrant is the Schema for the kuadrants API - displayName: Kuadrant - kind: Kuadrant - name: kuadrants.kuadrant.io - version: v1beta1 - description: Kuadrant Operator - displayName: Kuadrant - icon: - - base64data: iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAIAAAAiOjnJAAAHCklEQVR4nOzc72tWdQPH8e+tm/ecXGNO77mb3beZLgtkDxpCgT4I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woIEYUGCsCBBWJAgLEgQFiQICxKEBQnCggRhQYKwIEFYkCAsSBAWJAgLEoQFCcKCBGFBgrAgQViQICxIEBYkCAsShAUJwoIEYUGCsCBBWJAgLEgQFiQICxKEBQnCggRhQYKwIEFYkCAsSBAWJAgLEoQFCcKCBGFBgrAgQViQICxI/B0AAP//uLJ9vDn6iowAAAAASUVORK5CYII= - mediatype: image/png - install: - spec: - deployments: null - strategy: "" - installModes: - - supported: false - type: OwnNamespace - - supported: false - type: SingleNamespace - - supported: false - type: MultiNamespace - - supported: true - type: AllNamespaces - keywords: - - api - - api-management - - Kuadrant - links: - - name: Kuadrant Operator - url: https://github.com/Kuadrant/kuadrant-operator - - name: Kuadrant Docs - url: https://kuadrant.io - maintainers: - - email: eastizle@redhat.com - name: Eguzki Astiz Lezaun - - email: mcassola@redhat.com - name: Guilherme Cassolato - - email: didier@redhat.com - name: Didier Di Cesare - maturity: alpha - minKubeVersion: 1.8.0 - provider: - name: Red Hat - url: https://github.com/Kuadrant/kuadrant-operator - version: ${BUNDLE_VERSION} diff --git a/config/manifests/bases/kuadrant-operator.clusterserviceversion.yaml b/config/manifests/bases/kuadrant-operator.clusterserviceversion.yaml index 8acce6109..335d06a0d 100644 --- a/config/manifests/bases/kuadrant-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/kuadrant-operator.clusterserviceversion.yaml @@ -16,38 +16,38 @@ spec: apiservicedefinitions: {} customresourcedefinitions: owned: - - description: Kuadrant is the Schema for the kuadrants API - displayName: Kuadrant - kind: Kuadrant - name: kuadrants.kuadrant.io - version: v1beta1 + - description: Kuadrant is the Schema for the kuadrants API + displayName: Kuadrant + kind: Kuadrant + name: kuadrants.kuadrant.io + version: v1beta1 description: Kuadrant Operator displayName: Kuadrant icon: - - base64data: iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAIAAAAiOjnJAAAHCklEQVR4nOzc72tWdQPH8e+tm/ecXGNO77mb3beZLgtkDxpCgT4IBBFqJ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JcdvWrKY3nRxHh7CS46qtynVLg/qFzKgIK1G2rXxer1BSV/W/tW84HSVBWEkrrV04d3dL7LZmNb3qepEEYXlQVF4Zr63ql5eH8IqiKAjLjxhtZeprZzzxonKUS4TlTU5tFddkbt/0jn6UM4TlU8S2JlZMmrP17WC/vRkVYXkWpa3qxtVpubS6hrD8G7utynVLQ/5OMBvCCkK2tsqX3ZuKp1YjEVYoRraVqa+d/foer6PiI6yADG+rpK4qXbeBNynyPSCSmrxf2FpRUeFoi5Zt60zzxpmNW9J1G3iTfw0MDPjegALERyEkCAsShAUJwoIEYUGCsCBBWJAgLEgQFiQICxKEBQnCggRhQYKwIEFYkCAsSBAWJAgLEoQFCcKCBGFBgrAgQViQICxIEBYkCAsShAUJwoIEYUGCsCBBWJAgLEgQFiQICxKEBQnCggRhQYKwIEFYkCAsSBAWJAgLEoQFCcKCBGFBgrAgQViQICxI/B0AAP//uLJ9vDn6iowAAAAASUVORK5CYII= + mediatype: image/png install: spec: deployments: null strategy: "" installModes: - - supported: false - type: OwnNamespace - - supported: false - type: SingleNamespace - - supported: false - type: MultiNamespace - - supported: true - type: AllNamespaces + - supported: false + type: OwnNamespace + - supported: false + type: SingleNamespace + - supported: false + type: MultiNamespace + - supported: true + type: AllNamespaces keywords: - - api - - api-management - - Kuadrant + - api + - api-management + - Kuadrant links: - - name: Kuadrant Operator - url: https://github.com/Kuadrant/kuadrant-operator - - name: Kuadrant Docs - url: https://kuadrant.io + - name: Kuadrant Operator + url: https://github.com/Kuadrant/kuadrant-operator + - name: Kuadrant Docs + url: https://kuadrant.io maintainers: - email: eastizle@redhat.com name: Eguzki Astiz Lezaun diff --git a/doc/development.md b/doc/development.md index 4bf171420..ffec28937 100644 --- a/doc/development.md +++ b/doc/development.md @@ -1,5 +1,27 @@ # Development Guide + + * [Technology stack required for development](#technology-stack-required-for-development) + * [Build](#build) + * [Run locally](#run-locally) + * [Deploy the operator in a deployment object](#deploy-the-operator-in-a-deployment-object) + * [Deploy kuadrant operator using OLM](#deploy-kuadrant-operator-using-olm) + * [Build custom OLM catalog](#build-custom-olm-catalog) + * [Build kuadrant operator bundle image](#build-kuadrant-operator-bundle-image) + * [Build custom catalog](#build-custom-catalog) + * [Deploy kuadrant operator using OLM](#deploy-kuadrant-operator-using-olm-1) + * [Cleaning up](#cleaning-up) + * [Run tests](#run-tests) + * [Unit tests](#unittests) + * [Integration tests](#integration-tests) + * [All tests](#all-tests) + * [Lint tests](#lint-tests) + * [(Un)Install Kuadrant CRDs](#uninstall-kuadrant-crds) + + + + + ## Technology stack required for development * [operator-sdk] version v1.22.0 @@ -43,6 +65,145 @@ List of tasks done by the command above: * Build kuadrant docker image from the current working directory * Deploy Kuadrant control plane (including istio, authorino and limitador) +TODO: customize with custom authorino and limitador git refs. +Make sure Makefile propagates variable to `deploy` target + +## Deploy kuadrant operator using OLM + +You can deploy kuadrant using OLM just running few commands. +No need to build any image. Kuadrant engineering team provides `latest` and +release version tagged images. They are available in +the [Quay.io/Kuadrant](https://quay.io/organization/kuadrant) image repository. + +Create kind cluster + +``` +make kind-create-cluster +``` + +Deploy OLM system + +``` +make install-olm +``` + +Deploy kuadrant using OLM. The `make deploy-catalog` target accepts the following variables: + +| **Makefile Variable** | **Description** | **Default value** | +| --- | --- | --- | +| `CATALOG_IMG` | Kuadrant operator catalog image URL | `quay.io/kuadrant/kuadrant-operator-catalog:latest` | + +``` +make deploy-catalog [CATALOG_IMG=quay.io/kuadrant/kuadrant-operator-catalog:latest] +``` + +## Build custom OLM catalog + +If you want to deploy (using OLM) a custom kuadrant operator, you need to build your own catalog. +Furthermore, if you want to deploy a custom limitador or authorino operator, you also need +to build your own catalog. The kuadrant operator bundle includes the authorino or limtador operator +dependency version, hence using other than `latest` version requires a custom kuadrant operator +bundle and a custom catalog including the custom bundle. + +### Build kuadrant operator bundle image + +The `make bundle` target accepts the following variables: + +| **Makefile Variable** | **Description** | **Default value** | +| --- | --- | --- | +| `IMG` | Kuadrant operator image URL | `quay.io/kuadrant/kuadrant-operator:latest` | +| `VERSION` | Bundle version | `0.0.0` | +| `LIMITADOR_OPERATOR_BUNDLE_IMG` | Limitador operator bundle URL | `quay.io/kuadrant/limitador-operator-bundle:latest` | +| `AUTHORINO_OPERATOR_BUNDLE_IMG` | Authorino operator bundle URL | `quay.io/kuadrant/authorino-operator-bundle:latest` | + +* Build the bundle manifests + +```bash + +make bundle [IMG=quay.io/kuadrant/kuadrant-operator:latest] \ + [VERSION=0.0.0] \ + [LIMITADOR_OPERATOR_BUNDLE_IMG=quay.io/kuadrant/limitador-operator-bundle:latest] \ + [AUTHORINO_OPERATOR_BUNDLE_IMG=quay.io/kuadrant/authorino-operator-bundle:latest] +``` + +* Build the bundle image from the manifests + +| **Makefile Variable** | **Description** | **Default value** | +| --- | --- | --- | +| `BUNDLE_IMG` | Kuadrant operator bundle image URL | `quay.io/kuadrant/kuadrant-operator-bundle:latest` | + +```bash +make bundle-build [BUNDLE_IMG=quay.io/kuadrant/kuadrant-operator-bundle:latest] +``` + +* Push the bundle image to a registry + +| **Makefile Variable** | **Description** | **Default value** | +| --- | --- | --- | +| `BUNDLE_IMG` | Kuadrant operator bundle image URL | `quay.io/kuadrant/kuadrant-operator-bundle:latest` | + +```bash +make bundle-push [BUNDLE_IMG=quay.io/kuadrant/kuadrant-operator-bundle:latest] +``` + +Frequently, you may need to build custom kuadrant bundle with the default (`latest`) Limitador and +Authorino bundles. These are the example commands to build the manifests, build the bundle image +and push to the regitry. + +In the example, a new kuadrant operator bundle version `0.8.0` will be created that references +the kuadrant operator image `quay.io/kuadrant/kuadrant-operator:v0.5.0` and latest Limitador and +Authorino bundles. + +```bash +# manifests +make bundle IMG=quay.io/kuadrant/kuadrant-operator:v0.5.0 VERSION=0.8.0 + +# bundle image +make bundle-build BUNDLE_IMG=quay.io/kuadrant/kuadrant-operator-bundle:my-bundle + +# push bundle image +make bundle-push BUNDLE_IMG=quay.io/kuadrant/kuadrant-operator-bundle:my-bundle +``` + +### Build custom catalog + +The catalog's format will be [File-based Catalg](https://olm.operatorframework.io/docs/reference/file-based-catalogs/). + +Make sure all the required bundles are pushed to the registry. It is required by the `opm` tool. + +The `make catalog` target accepts the following variables: + +| **Makefile Variable** | **Description** | **Default value** | +| --- | --- | --- | +| `BUNDLE_IMG` | Kuadrant operator bundle image URL | `quay.io/kuadrant/kuadrant-operator-bundle:latest` | +| `LIMITADOR_OPERATOR_BUNDLE_IMG` | Limitador operator bundle URL | `quay.io/kuadrant/limitador-operator-bundle:latest` | +| `AUTHORINO_OPERATOR_BUNDLE_IMG` | Authorino operator bundle URL | `quay.io/kuadrant/authorino-operator-bundle:latest` | + +```bash +make catalog [BUNDLE_IMG=quay.io/kuadrant/kuadrant-operator-bundle:latest] \ + [LIMITADOR_OPERATOR_BUNDLE_IMG=quay.io/kuadrant/limitador-operator-bundle:latest] \ + [AUTHORINO_OPERATOR_BUNDLE_IMG=quay.io/kuadrant/authorino-operator-bundle:latest] +``` + +* Build the catalog image from the manifests + +| **Makefile Variable** | **Description** | **Default value** | +| --- | --- | --- | +| `CATALOG_IMG` | Kuadrant operator catalog image URL | `quay.io/kuadrant/kuadrant-operator-catalog:latest` | + +```bash +make catalog-build [CATALOG_IMG=quay.io/kuadrant/kuadrant-operator-catalog:latest] +``` + +* Push the catalog image to a registry + +```bash +make catalog-push [CATALOG_IMG=quay.io/kuadrant/kuadrant-operator-bundle:latest] +``` + +You can try out your custom catalog image following the steps of the +[Deploy kuadrant operator using OLM](#deploy-kuadrant-operator-using-olm) section. + ## Cleaning up ``` @@ -99,10 +260,6 @@ $ make run-lint You need an active session open to a kubernetes cluster. -``` -$ make install -``` - Remove CRDs ``` diff --git a/make/act.mk b/make/act.mk index 2aa792fb9..7d553d2f4 100644 --- a/make/act.mk +++ b/make/act.mk @@ -3,10 +3,6 @@ ## Targets to help test GitHub Actions locally using act https://github.com/nektos/act -ACT = $(shell pwd)/bin/act -act: ## Download act locally if necessary. - $(call go-get-tool,$(ACT),github.com/nektos/act@latest) - .PHONY: act-pull-request-jobs act-pull-request-jobs: act kind ## Run pull request jobs. $(ACT) pull_request --privileged diff --git a/make/catalog.mk b/make/catalog.mk new file mode 100644 index 000000000..a19bfaaf0 --- /dev/null +++ b/make/catalog.mk @@ -0,0 +1,50 @@ +##@ Operator Catalog + + +# The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0). +CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:$(IMAGE_TAG) + +CATALOG_FILE = $(PROJECT_PATH)/catalog/kuadrant-operator-catalog/operator.yaml +CATALOG_DOCKERFILE = $(PROJECT_PATH)/catalog/kuadrant-operator-catalog.Dockerfile + +$(CATALOG_DOCKERFILE): $(OPM) + -mkdir -p $(PROJECT_PATH)/catalog/kuadrant-operator-catalog + cd $(PROJECT_PATH)/catalog && $(OPM) generate dockerfile kuadrant-operator-catalog +catalog-dockerfile: $(CATALOG_DOCKERFILE) ## Generate catalog dockerfile. + +$(CATALOG_FILE): $(OPM) $(YQ) + @echo "************************************************************" + @echo Build kuadrant operator catalog + @echo + @echo BUNDLE_IMG = $(BUNDLE_IMG) + @echo LIMITADOR_OPERATOR_BUNDLE_IMG = $(LIMITADOR_OPERATOR_BUNDLE_IMG) + @echo AUTHORINO_OPERATOR_BUNDLE_IMG = $(AUTHORINO_OPERATOR_BUNDLE_IMG) + @echo "************************************************************" + @echo + @echo Please check this matches your expectations and override variables if needed. + @echo + $(PROJECT_PATH)/utils/generate-catalog.sh $(OPM) $(YQ) $(BUNDLE_IMG) \ + $(LIMITADOR_OPERATOR_BUNDLE_IMG) $(AUTHORINO_OPERATOR_BUNDLE_IMG) $@ + +.PHONY: catalog +catalog: $(OPM) ## Generate catalog content and validate. + # Initializing the Catalog + -rm -rf $(PROJECT_PATH)/catalog/kuadrant-operator-catalog + -rm -rf $(PROJECT_PATH)/catalog/kuadrant-operator-catalog.Dockerfile + $(MAKE) $(CATALOG_DOCKERFILE) + $(MAKE) $(CATALOG_FILE) LIMITADOR_OPERATOR_BUNDLE_IMG=$(LIMITADOR_OPERATOR_BUNDLE_IMG) \ + AUTHORINO_OPERATOR_BUNDLE_IMG=$(AUTHORINO_OPERATOR_BUNDLE_IMG) \ + BUNDLE_IMG=$(BUNDLE_IMG) + cd $(PROJECT_PATH)/catalog && $(OPM) validate kuadrant-operator-catalog + +# Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'. +# Ref https://olm.operatorframework.io/docs/tasks/creating-a-catalog/#catalog-creation-with-raw-file-based-catalogs +.PHONY: catalog-build +catalog-build: ## Build a catalog image. + # Build the Catalog + docker build $(PROJECT_PATH)/catalog -f $(PROJECT_PATH)/catalog/kuadrant-operator-catalog.Dockerfile -t $(CATALOG_IMG) + +# Push the catalog image. +.PHONY: catalog-push +catalog-push: ## Push a catalog image. + $(MAKE) docker-push IMG=$(CATALOG_IMG) diff --git a/make/kind.mk b/make/kind.mk index c5d4222a7..4c26b5b9b 100644 --- a/make/kind.mk +++ b/make/kind.mk @@ -3,10 +3,6 @@ ## Targets to help install and use kind for development https://kind.sigs.k8s.io -KIND = $(shell pwd)/bin/kind -kind: ## Download kind locally if necessary. - $(call go-get-tool,$(KIND),sigs.k8s.io/kind@v0.11.1) - KIND_CLUSTER_NAME ?= kuadrant-local .PHONY: kind-create-cluster diff --git a/pkg/common/yaml_decoder.go b/pkg/common/yaml_decoder.go index 07293d41d..ddc956bad 100644 --- a/pkg/common/yaml_decoder.go +++ b/pkg/common/yaml_decoder.go @@ -5,7 +5,6 @@ import ( "context" "errors" "io" - "io/ioutil" "github.com/go-logr/logr" "k8s.io/apimachinery/pkg/runtime" @@ -22,7 +21,7 @@ func DecodeFile(ctx context.Context, fileData []byte, scheme *runtime.Scheme, cb // the maximum size used to buffer a doc 5M buf := make([]byte, 5*1024*1024) - docDecoder := yaml.NewDocumentDecoder(ioutil.NopCloser(bytes.NewReader(fileData))) + docDecoder := yaml.NewDocumentDecoder(io.NopCloser(bytes.NewReader(fileData))) for { n, err := docDecoder.Read(buf) diff --git a/utils/dependencies-template.yaml b/utils/dependencies-template.yaml deleted file mode 100755 index e31c97d47..000000000 --- a/utils/dependencies-template.yaml +++ /dev/null @@ -1,9 +0,0 @@ -dependencies: - - type: olm.package - value: - packageName: authorino-operator - version: "%AUTHORINO_OPERATOR_BUNDLE_VERSION%" - - type: olm.package - value: - packageName: limitador-operator - version: "%LIMITADOR_OPERATOR_BUNDLE_VERSION%" diff --git a/utils/generate-catalog.sh b/utils/generate-catalog.sh new file mode 100755 index 000000000..8ef72be77 --- /dev/null +++ b/utils/generate-catalog.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash + +# Generate OLM catalog file + +set -euo pipefail + +### CONSTANTS +# Used as well in the subscription object +CHANNEL_NAME=preview +### + +OPM="${1?:Error \$OPM not set. Bye}" +YQ="${2?:Error \$YQ not set. Bye}" +BUNDLE_IMG="${3?:Error \$BUNDLE_IMG not set. Bye}" +LIMITADOR_OPERATOR_BUNDLE_IMG="${4?:Error \$LIMITADOR_OPERATOR_BUNDLE_IMG not set. Bye}" +AUTHORINO_OPERATOR_BUNDLE_IMG="${5?:Error \$AUTHORINO_OPERATOR_BUNDLE_IMG not set. Bye}" +CATALOG_FILE="${6?:Error \$CATALOG_FILE not set. Bye}" + +CATALOG_FILE_BASEDIR="$( cd "$( dirname "$(realpath ${CATALOG_FILE})" )" && pwd )" +CATALOG_BASEDIR="$( cd "$( dirname "$(realpath ${CATALOG_FILE_BASEDIR})" )" && pwd )" + +TMP_DIR=$(mktemp -d) + +${OPM} render ${BUNDLE_IMG} --output=yaml >> ${TMP_DIR}/kuadrant-operator-bundle.yaml +${OPM} render ${LIMITADOR_OPERATOR_BUNDLE_IMG} --output=yaml >> ${TMP_DIR}/limitador-operator-bundle.yaml +${OPM} render ${AUTHORINO_OPERATOR_BUNDLE_IMG} --output=yaml >> ${TMP_DIR}/authorino-operator-bundle.yaml + +# Verify kuadrant operator bundle's limitador/authorino references are the same +# as provided by LIMITADOR_OPERATOR_BUNDLE_IMG and AUTHORINO_OPERATOR_BUNDLE_IMG +LIMITADOR_VERSION=`${YQ} eval '.properties[] | select(.type == "olm.package") | .value.version' ${TMP_DIR}/limitador-operator-bundle.yaml` +AUTHORINO_VERSION=`${YQ} eval '.properties[] | select(.type == "olm.package") | .value.version' ${TMP_DIR}/authorino-operator-bundle.yaml` +LIMITADOR_REFERENCED_VERSION=`${YQ} eval '.properties[] | select(.type == "olm.package.required") | select(.value.packageName == "limitador-operator").value.versionRange' ${TMP_DIR}/kuadrant-operator-bundle.yaml` +AUTHORINO_REFERENCED_VERSION=`${YQ} eval '.properties[] | select(.type == "olm.package.required") | select(.value.packageName == "authorino-operator").value.versionRange' ${TMP_DIR}/kuadrant-operator-bundle.yaml` + +if [[ "${LIMITADOR_VERSION}" != "${LIMITADOR_REFERENCED_VERSION}" ]] +then + echo -e "\033[31m[ERROR] Referenced Limitador version is ${LIMITADOR_REFERENCED_VERSION}, but found ${LIMITADOR_VERSION} in the bundle \033[0m" >/dev/stderr + exit 1 +fi + +if [[ "${AUTHORINO_VERSION}" != "${AUTHORINO_REFERENCED_VERSION}" ]] +then + echo -e "\033[31mReferenced Limitador version is ${AUTHORINO_REFERENCED_VERSION}, but found ${AUTHORINO_VERSION} in the bundle \033[0m" >/dev/stderr + exit 1 +fi + +mkdir -p ${CATALOG_FILE_BASEDIR} +touch ${CATALOG_FILE} + +### +# Limitador Operator +### +# Add the package +${OPM} init limitador-operator --default-channel=${CHANNEL_NAME} --output yaml >> ${CATALOG_FILE} +# Add a bundles to the Catalog +cat ${TMP_DIR}/limitador-operator-bundle.yaml >> ${CATALOG_FILE} +# Add a channel entry for the bundle +V=`${YQ} eval '.name' ${TMP_DIR}/limitador-operator-bundle.yaml` \ + ${YQ} eval '(.entries[0].name = strenv(V))' ${CATALOG_BASEDIR}/limitador-operator-channel-entry.yaml >> ${CATALOG_FILE} + +### +# Authorino Operator +### +# Add the package +${OPM} init authorino-operator --default-channel=${CHANNEL_NAME} --output yaml >> ${CATALOG_FILE} +# Add a bundles to the Catalog +cat ${TMP_DIR}/authorino-operator-bundle.yaml >> ${CATALOG_FILE} +# Add a channel entry for the bundle +V=`${YQ} eval '.name' ${TMP_DIR}/authorino-operator-bundle.yaml` \ + ${YQ} eval '(.entries[0].name = strenv(V))' ${CATALOG_BASEDIR}/authorino-operator-channel-entry.yaml >> ${CATALOG_FILE} + +### +# Kuadrant Operator +### +# Add the package +${OPM} init kuadrant-operator --default-channel=${CHANNEL_NAME} --output yaml >> ${CATALOG_FILE} +# Add a bundles to the Catalog +cat ${TMP_DIR}/kuadrant-operator-bundle.yaml >> ${CATALOG_FILE} +# Add a channel entry for the bundle +V=`${YQ} eval '.name' ${TMP_DIR}/kuadrant-operator-bundle.yaml` \ + ${YQ} eval '(.entries[0].name = strenv(V))' ${CATALOG_BASEDIR}/kuadrant-operator-channel-entry.yaml >> ${CATALOG_FILE} + +rm -rf $TMP_DIR diff --git a/utils/generate-dependencies-yaml.sh b/utils/generate-dependencies-yaml.sh deleted file mode 100755 index 8aecb5e2f..000000000 --- a/utils/generate-dependencies-yaml.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -sed \ -"s/%AUTHORINO_OPERATOR_BUNDLE_VERSION%/${AUTHORINO_OPERATOR_BUNDLE_VERSION}/g; \ -s/%LIMITADOR_OPERATOR_BUNDLE_VERSION%/${LIMITADOR_OPERATOR_BUNDLE_VERSION}/g" \ -${SCRIPTS_DIR}/dependencies-template.yaml diff --git a/utils/parse-bundle-version.sh b/utils/parse-bundle-version.sh new file mode 100755 index 000000000..d1babf202 --- /dev/null +++ b/utils/parse-bundle-version.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -euo pipefail + +OPM=$1 +YQ=$2 +BUNDLE_IMAGE=$3 + +$OPM render $BUNDLE_IMAGE | $YQ eval '.properties[] | select(.type == "olm.package") | .value.version' -