Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,29 @@ git status
export OPERATOR_IMAGE="quay.io/redhat-user-workloads/kueue-operator-tenant/${OPERATOR_COMPONENT}:on-pr-${REVISION}"
echo "export OPERATOR_IMAGE=${OPERATOR_IMAGE}" >> "${SHARED_DIR}/env"

REPO="quay.io/redhat-user-workloads/kueue-operator-tenant/${BUNDLE_COMPONENT}"
BUNDLE_IMAGE=$(skopeo list-tags docker://$REPO | jq -r '.Tags[]' | grep -E '^[a-f0-9]{40}$' | while read -r tag; do
created=$(skopeo inspect docker://$REPO:$tag 2>/dev/null | jq -r '.Created')
resolve_latest_image() {
local repo=$1
skopeo list-tags "docker://$repo" | jq -r '.Tags[]' | grep -E '^[a-f0-9]{40}$' | while read -r tag; do
created=$(skopeo inspect "docker://$repo:$tag" 2>/dev/null | jq -r '.Created')
if [ "$created" != "null" ] && [ -n "$created" ]; then echo "$created $tag"; fi
done | sort | tail -n1 | awk -v repo="$REPO" '{print repo ":" $2}')
done | sort | tail -n1 | awk -v repo="$repo" '{print repo ":" $2}'
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}

if [[ -z "$BUNDLE_IMAGE" ]]; then
echo "ERROR: Failed to resolve BUNDLE_IMAGE from $REPO"
OPERAND_REPO="quay.io/redhat-user-workloads/kueue-operator-tenant/${OPERAND_COMPONENT}"
OPERAND_IMAGE=$(resolve_latest_image "$OPERAND_REPO")
if [[ -z "$OPERAND_IMAGE" ]]; then
echo "ERROR: Failed to resolve OPERAND_IMAGE from $OPERAND_REPO"
exit 1
fi
echo "Resolved OPERAND_IMAGE: ${OPERAND_IMAGE}"
echo "export OPERAND_IMAGE=${OPERAND_IMAGE}" >> "${SHARED_DIR}/env"

BUNDLE_REPO="quay.io/redhat-user-workloads/kueue-operator-tenant/${BUNDLE_COMPONENT}"
BUNDLE_IMAGE=$(resolve_latest_image "$BUNDLE_REPO")
if [[ -z "$BUNDLE_IMAGE" ]]; then
echo "ERROR: Failed to resolve BUNDLE_IMAGE from $BUNDLE_REPO"
exit 1
fi
echo "Resolved BUNDLE_IMAGE: ${BUNDLE_IMAGE}"
echo "export BUNDLE_IMAGE=${BUNDLE_IMAGE}" >> "${SHARED_DIR}/env"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,23 @@ echo "Installing CI-built bundle via operator-sdk..."
oc apply --server-side --force-conflicts -f bindata/assets/kueue-operator/crds/
oc apply --server-side --force-conflicts -f deploy/crd/kueue-operator.crd.yaml

echo "Patching CSV with operator image..."
echo "Patching CSV with operator and operand images..."
PATCHED_CSV=$(oc get csv -n "${NAMESPACE}" --sort-by=.metadata.creationTimestamp -o jsonpath='{.items[*].metadata.name}' 2>/dev/null | awk '{print $NF}')
if [[ -n "${PATCHED_CSV}" && -n "${OPERATOR_IMAGE:-}" ]]; then
oc patch csv "${PATCHED_CSV}" -n "${NAMESPACE}" --type='json' \
-p="[{\"op\": \"replace\", \"path\": \"/spec/install/spec/deployments/0/spec/template/spec/containers/0/image\", \"value\": \"${OPERATOR_IMAGE}\"}]"

if [[ -n "${OPERAND_IMAGE:-}" ]]; then
ENV_INDEX=$(oc get csv "${PATCHED_CSV}" -n "${NAMESPACE}" -o json | \
jq -r '(.spec.install.spec.deployments[0].spec.template.spec.containers[0].env // []) | to_entries[] | select(.value.name == "RELATED_IMAGE_OPERAND_IMAGE") | .key')
if [[ -z "${ENV_INDEX}" ]]; then
echo "ERROR: RELATED_IMAGE_OPERAND_IMAGE env var not found in CSV ${PATCHED_CSV}"
exit 1
fi
echo "Patching RELATED_IMAGE_OPERAND_IMAGE at env index ${ENV_INDEX} to ${OPERAND_IMAGE}"
oc patch csv "${PATCHED_CSV}" -n "${NAMESPACE}" --type='json' \
-p="[{\"op\": \"replace\", \"path\": \"/spec/install/spec/deployments/0/spec/template/spec/containers/0/env/${ENV_INDEX}/value\", \"value\": \"${OPERAND_IMAGE}\"}]"
fi
else
echo "ERROR: Could not patch CSV (PATCHED_CSV=${PATCHED_CSV:-empty}, OPERATOR_IMAGE=${OPERATOR_IMAGE:-empty})"
exit 1
Expand Down