diff --git a/.ci/oci-single-host.sh b/.ci/oci-single-host.sh index 4697bd52b7..670f4c4810 100755 --- a/.ci/oci-single-host.sh +++ b/.ci/oci-single-host.sh @@ -31,15 +31,16 @@ overrideDefaults() { } runTests() { - # create namespace oc create namespace ${NAMESPACE} || true - # Deploy Eclipse Che applying CR - applyOlmCR + useCustomOperatorImageInCSV ${OPERATOR_IMAGE} + createEclipseCheCRFromCSV + waitEclipseCheDeployed "next" waitDevWorkspaceControllerStarted } initDefaults overrideDefaults + runTests diff --git a/.github/bin/common.sh b/.github/bin/common.sh index 88a7ea5165..12f8bf85fc 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -33,8 +33,6 @@ initDefaults() { export ARTIFACTS_DIR=${ARTIFACT_DIR:-"/tmp/artifacts-che"} export CHECTL_TEMPLATES_BASE_DIR=/tmp/chectl-templates export OPERATOR_IMAGE="test/che-operator:test" - export OPENSHIFT_NEXT_CSV_FILE="${OPERATOR_REPO}/bundle/next/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml" - export IMAGE_PULLER_ENABLE="false" export IS_OPENSHIFT=$(kubectl api-resources --api-group="route.openshift.io" --no-headers=true | head -n1 | wc -l) export IS_KUBERNETES=$(if [[ $IS_OPENSHIFT == 0 ]]; then echo 1; else echo 0; fi) @@ -305,27 +303,21 @@ enableImagePuller() { kubectl patch checluster/eclipse-che -n ${NAMESPACE} --type=merge -p '{"spec":{"imagePuller":{"enable": true}}}' } -# Patch subscription with image builded from source in Openshift CI job. -patchEclipseCheOperatorImage() { - OPERATOR_POD=$(oc get pods -o json -n ${NAMESPACE} | jq -r '.items[] | select(.metadata.name | test("che-operator-")).metadata.name') - oc patch pod ${OPERATOR_POD} -n ${NAMESPACE} --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":'${OPERATOR_IMAGE}'}]' - - # The following command retrieve the operator image - OPERATOR_POD_IMAGE=$(oc get pods -n ${NAMESPACE} -o json | jq -r '.items[] | select(.metadata.name | test("che-operator-")).spec.containers[].image') - echo -e "[INFO] CHE operator image is ${OPERATOR_POD_IMAGE}" +useCustomOperatorImageInCSV() { + local image=$1 + oc patch csv $(getCSVName) -n openshift-operators --type=json -p '[{"op": "replace", "path": "/spec/install/spec/deployments/0/spec/template/spec/containers/0/image", "value": "'${image}'"}]' } -# Create CheCluster object in Openshift ci with desired values -applyOlmCR() { - echo "Creating Custom Resource" - - CR=$(yq -r ".metadata.annotations[\"alm-examples\"] | fromjson | .[] | select(.kind == \"CheCluster\")" "${OPENSHIFT_NEXT_CSV_FILE}") - CR=$(echo "$CR" | yq -r ".spec.imagePuller.enable = ${IMAGE_PULLER_ENABLE:-false}") - - echo -e "$CR" +createEclipseCheCRFromCSV() { + local cr=$(oc get csv $(getCSVName) -n openshift-operators -o yaml | yq -r ".metadata.annotations[\"alm-examples\"] | fromjson | .[] | select(.kind == \"CheCluster\")") + cr=$(echo "$cr" | yq -r ".spec.imagePuller.enable = ${IMAGE_PULLER_ENABLE:-false}") echo "$CR" | oc apply -n "${NAMESPACE}" -f - } +getCSVName() { + echo $(oc get csv -n openshift-operators | grep eclipse-che-preview-openshift | awk '{print $1}') +} + # Deploy Eclipse Che behind proxy in openshift ci deployCheBehindProxy() { chectl server:deploy \ diff --git a/olm/buildCatalog.sh b/olm/buildCatalog.sh index c56414a174..b729d2447a 100755 --- a/olm/buildCatalog.sh +++ b/olm/buildCatalog.sh @@ -78,7 +78,7 @@ buildBundle() { buildCatalog () { if [ $(isCatalogExists) == 0 ]; then - echo "[INFO] Bundle a new catalog" + echo "[INFO] Build a new catalog" buildCatalogImage "${CATALOG_IMAGE}" "${BUNDLE_IMAGE}" "docker" "${FORCE}" else if [[ $(isBundleExistsInCatalog) == 0 ]]; then @@ -91,7 +91,7 @@ buildCatalog () { } isBundleExistsInCatalog() { - local BUNDLE_NAME=$(docker run --entrypoint sh ${CATALOG_IMAGE} -c "apk add sqlite && sqlite3 /database/index.db 'SELECT head_operatorbundle_name FROM channel WHERE name = \"${CHANNEL}\" and head_operatorbundle_name = \"${CSV_NAME}\"'" | tail -n1 | tr -d '\r') + local BUNDLE_NAME=$(docker run --entrypoint sh ${CATALOG_IMAGE} -c "apk add sqlite && sqlite3 /database/index.db 'SELECT operatorbundle_name FROM channel_entry WHERE channel_name=\"${CHANNEL}\" and operatorbundle_name=\"${CSV_NAME}\"'" | tail -n1 | tr -d '\r') # docker run produce more output then a single line # so, it is needed to check if the last line is actually a given bunle name diff --git a/olm/olm.sh b/olm/olm.sh index 8d08c19d7a..927e7709e2 100755 --- a/olm/olm.sh +++ b/olm/olm.sh @@ -297,7 +297,7 @@ subscribeToInstallation() { fi # fourth argument is an optional - CSV_NAME="${4-${CSV_NAME}}" + CSV_NAME="${3-${CSV_NAME}}" if [ -n "${CSV_NAME}" ]; then echo "[INFO] Subscribing to the version: '${CSV_NAME}'" else @@ -364,9 +364,7 @@ installPackage() { applyCheClusterCR() { CSV_NAME=${1} - CHECLUSTER=$(kubectl get csv ${CSV_NAME} -n ${NAMESPACE} -o yaml \ - | yq -r ".metadata.annotations[\"alm-examples\"] | fromjson | .[] | select(.kind == \"CheCluster\")" \ - | yq -r ".spec.imagePuller.enable = ${IMAGE_PULLER_ENABLE:-false}") + CHECLUSTER=$(kubectl get csv ${CSV_NAME} -n ${NAMESPACE} -o yaml | yq -r ".metadata.annotations[\"alm-examples\"] | fromjson | .[] | select(.kind == \"CheCluster\")") echo "[INFO] Creating Custom Resource: " echo "${CHECLUSTER}"