|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# Copyright (c) 2020, 2025, Oracle and/or its affiliates. |
| 4 | +# Licensed under the Universal Permissive License v 1.0 as shown at |
| 5 | +# http://oss.oracle.com/licenses/upl. |
| 6 | +# |
| 7 | + |
| 8 | +ROOT_DIR=$(pwd) |
| 9 | +BUILD_DIR="${ROOT_DIR}/build" |
| 10 | +OUTPUT_DIR="${BUILD_DIR}/_output" |
| 11 | + |
| 12 | +mkdir -p "${OUTPUT_DIR}" || true |
| 13 | + |
| 14 | +if [ -z "${SUBMIT_RESULTS:-}" ]; then |
| 15 | + SUBMIT_RESULTS=false |
| 16 | +fi |
| 17 | + |
| 18 | +if [ "${SUBMIT_RESULTS}" = "true" ]; then |
| 19 | + if [ -z "${OPENSHIFT_API_KEY:-}" ]; then |
| 20 | + echo "Error: SUBMIT_RESULTS is set to 'true' but OPENSHIFT_API_KEY is not set" |
| 21 | + exit 1 |
| 22 | + fi |
| 23 | + if [ -z "${OPENSHIFT_IMAGE_COMPONENT_ID:-}" ]; then |
| 24 | + OPENSHIFT_IMAGE_COMPONENT_ID="67bdf00eb9f79dcdb25aa8e2" |
| 25 | + fi |
| 26 | + EXTRA_ARGS="--pyxis-api-token=${OPENSHIFT_API_KEY} --certification-component-id=${OPENSHIFT_IMAGE_COMPONENT_ID}" |
| 27 | +else |
| 28 | + EXTRA_ARGS="" |
| 29 | +fi |
| 30 | + |
| 31 | +if [ "${USE_LATEST_OPERATOR_RELEASE}" = "true" ]; then |
| 32 | + echo "Run preflight on latest release" |
| 33 | +# Find the latest release of the Coherence Operator on GitHub |
| 34 | + LATEST_RELEASE=$(gh release list --repo oracle/coherence-operator --json name,isLatest --jq '.[] | select(.isLatest)|.name') |
| 35 | +# Strip the v from the front of the release to give the Operator version |
| 36 | + OPERATOR_VERSION=${LATEST_RELEASE#"v"} |
| 37 | + echo "Latest Operator version is ${OPERATOR_VERSION}" |
| 38 | +# Check the latest release image exists on OCR |
| 39 | + COHERENCE_OPERATOR_IMAGE="container-registry.oracle.com/middleware/coherence-operator:${OPERATOR_VERSION}" |
| 40 | + echo "Checking Oracle Container Registry for image ${COHERENCE_OPERATOR_IMAGE}" |
| 41 | + docker manifest inspect "${COHERENCE_OPERATOR_IMAGE}" > /dev/null |
| 42 | + if [ $? -ne 0 ]; then |
| 43 | + echo "ERROR: Image ${COHERENCE_OPERATOR_IMAGE} does not exist on OCR." |
| 44 | + exit 1 |
| 45 | + fi |
| 46 | +else |
| 47 | + echo "Run preflight on latest build" |
| 48 | +# We are just testing a local build, so use the current version |
| 49 | + OPERATOR_VERSION=$(cat "${BUILD_DIR}/_output/version.txt") |
| 50 | +# We will not be submitting results |
| 51 | + SUBMIT_RESULTS=false |
| 52 | + COHERENCE_OPERATOR_IMAGE="${REGISTRY_HOST}/${REGISTRY_NAMESPACE}/coherence-operator:${OPERATOR_VERSION}" |
| 53 | +fi |
| 54 | + |
| 55 | +echo "Running preflight on ${COHERENCE_OPERATOR_IMAGE}" |
| 56 | + |
| 57 | +PREFLIGHT_LOG="${OUTPUT_DIR}/preflight.log" |
| 58 | +preflight check container --submit="${SUBMIT_RESULTS}" --logfile="${PREFLIGHT_LOG}" ${EXTRA_ARGS} ${COHERENCE_OPERATOR_IMAGE} |
0 commit comments