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

SDCICD-1338: custom task to generate OLM catalog #1170

Merged
merged 1 commit into from
Jul 31, 2024
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
17 changes: 17 additions & 0 deletions task/opm-render-bundles/0.1/README.md
Original file line number Diff line number Diff line change
@@ -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|
69 changes: 69 additions & 0 deletions task/opm-render-bundles/0.1/opm-render-bundles.yaml
Original file line number Diff line number Diff line change
@@ -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
jbpratt marked this conversation as resolved.
Show resolved Hide resolved
- 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"
jbpratt marked this conversation as resolved.
Show resolved Hide resolved
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
jbpratt marked this conversation as resolved.
Show resolved Hide resolved

cat catalog/operator.yaml

opm validate catalog
6 changes: 6 additions & 0 deletions task/opm-render-bundles/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
approvers:
- jbpratt
- gurnben
reviewers:
- jbpratt
- gurnben
Loading