From d353d29f0699a0c53be218afe7e336fddc40a00d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ernesto=20Gonz=C3=A1lez?= Date: Wed, 30 Oct 2024 20:26:44 +0100 Subject: [PATCH] chore(KFLUXMIG-13): build mtv downstream bundle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ernesto González --- ...forklift-operator-bundle-pull-request.yaml | 2 + build/forklift-operator-bundle/Containerfile | 4 +- .../forklift-operator-bundle/downstream-args | 1 + build/forklift-operator-bundle/upstream-args | 1 + operator/export-vars.sh | 49 ++++++++++++++++--- 5 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 build/forklift-operator-bundle/downstream-args create mode 100644 build/forklift-operator-bundle/upstream-args mode change 100644 => 100755 operator/export-vars.sh diff --git a/.tekton/forklift-operator-bundle-pull-request.yaml b/.tekton/forklift-operator-bundle-pull-request.yaml index e8d7e2fcd..6223c7e9e 100644 --- a/.tekton/forklift-operator-bundle-pull-request.yaml +++ b/.tekton/forklift-operator-bundle-pull-request.yaml @@ -34,6 +34,8 @@ spec: value: build/forklift-operator-bundle/Containerfile - name: path-context value: . + - name: build-args-file + value: build/forklift-operator-bundle/downstream-args pipelineSpec: description: | This pipeline is ideal for building container images from a Containerfile while maintaining trust after pipeline customization. diff --git a/build/forklift-operator-bundle/Containerfile b/build/forklift-operator-bundle/Containerfile index c64079216..51f00672e 100644 --- a/build/forklift-operator-bundle/Containerfile +++ b/build/forklift-operator-bundle/Containerfile @@ -1,8 +1,10 @@ FROM quay.io/konflux-ci/operator-sdk-builder@sha256:73fa40301aebf0c62903a5840918251f444212319f95a4e467eeaf0cd8c4349e as builder +ARG STREAM=downstream + COPY ./. /repo WORKDIR /repo/operator -RUN source ./export-vars.sh && \ +RUN source ./export-vars.sh ${STREAM} && env && \ kustomize build config/manifests/ \ | envsubst \ | operator-sdk generate bundle \ diff --git a/build/forklift-operator-bundle/downstream-args b/build/forklift-operator-bundle/downstream-args new file mode 100644 index 000000000..21fd4d234 --- /dev/null +++ b/build/forklift-operator-bundle/downstream-args @@ -0,0 +1 @@ +STREAM=downstream diff --git a/build/forklift-operator-bundle/upstream-args b/build/forklift-operator-bundle/upstream-args new file mode 100644 index 000000000..a61453b92 --- /dev/null +++ b/build/forklift-operator-bundle/upstream-args @@ -0,0 +1 @@ +STREAM=upstream diff --git a/operator/export-vars.sh b/operator/export-vars.sh old mode 100644 new mode 100755 index 4d801a615..a05e3f3c2 --- a/operator/export-vars.sh +++ b/operator/export-vars.sh @@ -1,4 +1,13 @@ -#!/bin/bash -e +#!/bin/bash -ex + +# Check if the script has exactly one parameter +if [ "$#" -ne 1 ]; then + echo "Error: Exactly one parameter is required." + echo "Usage: $0 " + exit 1 +fi + +stream=$1 declare -A images @@ -26,13 +35,41 @@ images[VALIDATION_IMAGE]=quay.io/redhat-user-workloads/rh-mtv-1-tenant/forklift- images[VIRT_V2V_IMAGE]=quay.io/redhat-user-workloads/rh-mtv-1-tenant/forklift-operator/virt-v2v@sha256:17628ab1f836549509ad80c321f669441d3f15348a5ef151b69fbbcec03ccd30 +# For downstream, the names of the images change + +declare -A replacements + +replacements[API_IMAGE]=mtv-api-rhel9 +replacements[CONTROLLER_IMAGE]=mtv-controller-rhel8 +replacements[MUST_GATHER_IMAGE]=mtv-must-gather-rhel8 +replacements[OPENSTACK_POPULATOR_IMAGE]=mtv-openstack-populator-rhel9 +replacements[OPERATOR_IMAGE]=mtv-rhel8-operator +replacements[OVA_PROVIDER_SERVER_IMAGE]=mtv-ova-provider-server-rhel9 +replacements[OVIRT_POPULATOR_IMAGE]=mtv-rhv-populator-rhel8 +replacements[POPULATOR_CONTROLLER_IMAGE]=mtv-populator-controller-rhel9 +replacements[UI_PLUGIN_IMAGE]=mtv-console-plugin-rhel9 +replacements[VALIDATION_IMAGE]=mtv-validation-rhel8 +replacements[VIRT_V2V_IMAGE]=mtv-virt-v2v-rhel8 + # Chage the repository of the images to match the repository they would be pushed # to during a release. -for k in "${!images[@]}"; do - image="${images[$k]}" - new_image="${image/redhat-user-workloads\/rh-mtv-1-tenant/kubev2v}" - export "$k=$new_image" -done +if [ $stream == "upstream" ]; then + for k in "${!images[@]}"; do + image="${images[$k]}" + new_image="${image/quay.io\/redhat-user-workloads\/rh-mtv-1-tenant\/forklift-operator/kubev2v}" + export "$k=$new_image" + done +elif [ $stream == "downstream" ]; then + for k in "${!images[@]}"; do + image="${images[$k]}" + new_image="${image/forklift-operator\/[^@]*@/forklift-operator\/${replacements[$k]}@}" + new_image="${new_image/quay.io\/redhat-user-workloads\/rh-mtv-1-tenant\/forklift-operator/registry.redhat.io\/migration-toolkit-virtualization}" + export "$k=$new_image" + done +else + echo "Stream not valid. Expected 'upstream' or 'downstream'." + exit 1 +fi export VERSION="v2.7.0"