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

[workflow] Adding channels input for bundle creation #97

Merged
merged 3 commits into from
Sep 11, 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
24 changes: 20 additions & 4 deletions .github/workflows/build-images-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ on:
description: Limitador version
default: latest
type: string
channels:
description: Bundle and catalog channels, comma separated
default: preview
type: string
workflow_dispatch:
inputs:
operatorVersion:
Expand All @@ -29,6 +33,10 @@ on:
description: Limitador version
default: latest
type: string
channels:
description: Bundle and catalog channels, comma separated
default: preview
type: string

env:
IMG_TAGS: ${{ github.sha }} ${{ inputs.operatorTag }}
Expand Down Expand Up @@ -90,8 +98,13 @@ jobs:
- name: Run make bundle
id: make-bundle
run: |
make bundle REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} \
VERSION=${{ env.VERSION }} IMAGE_TAG=${{ inputs.operatorTag }} LIMITADOR_VERSION=${{ inputs.limitadorVersion }}
make bundle \
REGISTRY=${{ env.IMG_REGISTRY_HOST }} \
ORG=${{ env.IMG_REGISTRY_ORG }} \
VERSION=${{ env.VERSION }} \
IMAGE_TAG=${{ inputs.operatorTag }} \
LIMITADOR_VERSION=${{ inputs.limitadorVersion }} \
CHANNELS=${{ inputs.channels }}
- name: Build Image
id: build-image
uses: redhat-actions/buildah-build@v2
Expand Down Expand Up @@ -128,8 +141,11 @@ jobs:
uses: actions/checkout@v3
- name: Generate Catalog Content
run: |
make catalog REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} \
VERSION=${{ env.VERSION }} IMAGE_TAG=${{ inputs.operatorTag }} LIMITADOR_VERSION=${{ inputs.limitadorVersion }}
make catalog \
REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} \
VERSION=${{ env.VERSION }} IMAGE_TAG=${{ inputs.operatorTag }} \
LIMITADOR_VERSION=${{ inputs.limitadorVersion }} \
CHANNELS=${{ inputs.channels }}
- name: Install qemu dependency
run: |
sudo apt-get update
Expand Down
3 changes: 2 additions & 1 deletion make/catalog.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ $(CATALOG_FILE): $(OPM) $(YQ)
@echo Build limitador operator catalog
@echo
@echo BUNDLE_IMG = $(BUNDLE_IMG)
@echo CHANNELS = $(CHANNELS)
@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) $@
$(PROJECT_PATH)/utils/generate-catalog.sh $(OPM) $(YQ) $(BUNDLE_IMG) $(CHANNELS) $@

.PHONY: catalog
catalog: $(OPM) ## Generate catalog content and validate.
Expand Down
10 changes: 6 additions & 4 deletions utils/generate-catalog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ set -euo pipefail

### CONSTANTS
# Used as well in the subscription object
CHANNEL_NAME=preview
DEFAULT_CHANNEL=preview
###

OPM="${1?:Error \$OPM not set. Bye}"
YQ="${2?:Error \$YQ not set. Bye}"
BUNDLE_IMG="${3?:Error \$BUNDLE_IMG not set. Bye}"
CATALOG_FILE="${4?:Error \$CATALOG_FILE not set. Bye}"
CHANNELS="${4:-$DEFAULT_CHANNEL}"
CATALOG_FILE="${5?:Error \$CATALOG_FILE not set. Bye}"

CATALOG_FILE_BASEDIR="$( cd "$( dirname "$(realpath ${CATALOG_FILE})" )" && pwd )"
CATALOG_BASEDIR="$( cd "$( dirname "$(realpath ${CATALOG_FILE_BASEDIR})" )" && pwd )"
Expand All @@ -28,11 +29,12 @@ touch ${CATALOG_FILE}
# Limitador Operator
###
# Add the package
${OPM} init limitador-operator --default-channel=${CHANNEL_NAME} --output yaml >> ${CATALOG_FILE}
${OPM} init limitador-operator --default-channel=${CHANNELS} --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}
CHANNELS=${CHANNELS} \
${YQ} eval '(.entries[0].name = strenv(V)) | (.name = strenv(CHANNELS))' ${CATALOG_BASEDIR}/limitador-operator-channel-entry.yaml >> ${CATALOG_FILE}

rm -rf $TMP_DIR