From c22e71085168189deed1e85e5689d397355b42c5 Mon Sep 17 00:00:00 2001 From: Brady Pratt Date: Wed, 17 Jul 2024 06:56:00 -0500 Subject: [PATCH] SDCICD-1338: custom task to generate OLM catalog Add a new custom task to generate the OLM catalog based on a bundle image. This creates the Dockerfile and generates the catalog contents by adding a single bundle and a single channel entry for that bundle to the catalog with a skip range to the latest version. OLM can then be treated in such a way that it will always upgrade to the latest version available in the catalog. following the documentation[1] for creating raw FBCs [1]: https://olm.operatorframework.io/docs/tasks/creating-a-catalog/#catalog-creation-with-raw-file-based-catalogs PR #1153 will be used to generate the bundle that is fed into this task as a parameter. SRE-P operators are maintained without actively versioning or managing upgrade graphs; the latest version is always the version that should be running. Signed-off-by: Brady Pratt --- task/opm-render-bundles/0.1/README.md | 17 +++++ .../0.1/opm-render-bundles.yaml | 69 +++++++++++++++++++ task/opm-render-bundles/OWNERS | 6 ++ 3 files changed, 92 insertions(+) create mode 100644 task/opm-render-bundles/0.1/README.md create mode 100644 task/opm-render-bundles/0.1/opm-render-bundles.yaml create mode 100644 task/opm-render-bundles/OWNERS diff --git a/task/opm-render-bundles/0.1/README.md b/task/opm-render-bundles/0.1/README.md new file mode 100644 index 0000000000..9ed63ae8fb --- /dev/null +++ b/task/opm-render-bundles/0.1/README.md @@ -0,0 +1,17 @@ +# opm-render-bundles task + +Create a catalog index and render the provided bundles into it + +## Parameters +|name|description|default value|required| +|---|---|---|---| +|binary-image|Base image in which to use for the catalog image|registry.redhat.io/openshift4/ose-operator-registry:latest|false| +|bundle-images|Comma separated list of bundles to add||true| +|operator-name|Name of the Operator||true| +|operator-version|Version of the Operator||true| +|default-channel|The channel that subscriptions will default to if unspecified|stable|false| + +## Workspaces +|name|description|optional| +|---|---|---| +|source|Workspace with the source code|false| diff --git a/task/opm-render-bundles/0.1/opm-render-bundles.yaml b/task/opm-render-bundles/0.1/opm-render-bundles.yaml new file mode 100644 index 0000000000..441fd88544 --- /dev/null +++ b/task/opm-render-bundles/0.1/opm-render-bundles.yaml @@ -0,0 +1,69 @@ +--- +apiVersion: tekton.dev/v1beta1 +kind: Task +metadata: + name: opm-render-bundles +spec: + description: Create a catalog index and render the provided bundles into it + params: + - name: binary-image + description: Base image in which to use for the catalog image + default: registry.redhat.io/openshift4/ose-operator-registry:latest + - name: bundle-images + description: Comma separated list of bundles to add + - name: operator-name + description: Name of the Operator + - name: operator-version + description: Version of the Operator + - name: default-channel + description: The channel that subscriptions will default to if unspecified + default: stable + workspaces: + - name: source + description: Workspace with the source code + steps: + - name: opm-render-bundles + image: "registry.redhat.io/openshift4/ose-operator-registry:latest" + workingDir: $(workspaces.source.path)/source + securityContext: + runAsUser: 0 + env: + - name: BINARY_IMAGE + value: $(params.binary-image) + - name: BUNDLE_IMAGES + value: $(params.bundle-images) + - name: OPERATOR_NAME + value: $(params.operator-name) + - name: OPERATOR_VERSION + value: $(params.operator-version) + - name: DEFAULT_CHANNEL + value: $(params.default-channel) + script: | + #!/usr/bin/env bash + + set -xe + + mkdir -p catalog/ + + opm generate dockerfile catalog/ --binary-image="${BINARY_IMAGE}" + + opm init "${OPERATOR_NAME}" \ + --default-channel="${DEFAULT_CHANNEL}" \ + --description=./README.md \ + --output=yaml > catalog/operator.yaml + + opm render "${BUNDLE_IMAGES}" --output=yaml >> catalog/operator.yaml + + cat << EOF >> catalog/operator.yaml + --- + schema: olm.channel + package: "${OPERATOR_NAME}" + name: "${DEFAULT_CHANNEL}" + entries: + - name: ${OPERATOR_NAME}.${OPERATOR_VERSION} + skipRange: ">=0.0.1 <${OPERATOR_VERSION}" + EOF + + cat catalog/operator.yaml + + opm validate catalog diff --git a/task/opm-render-bundles/OWNERS b/task/opm-render-bundles/OWNERS new file mode 100644 index 0000000000..54bf30ad65 --- /dev/null +++ b/task/opm-render-bundles/OWNERS @@ -0,0 +1,6 @@ +approvers: +- jbpratt +- gurnben +reviewers: +- jbpratt +- gurnben