diff --git a/.ci/cico_updates_openshift.sh b/.ci/cico_updates_openshift.sh index 7066604aa8..76f0b09eb4 100755 --- a/.ci/cico_updates_openshift.sh +++ b/.ci/cico_updates_openshift.sh @@ -26,7 +26,7 @@ overrideDefaults() { } runTests() { - "${OPERATOR_REPO}"/olm/testUpdate.sh "openshift" "stable" ${NAMESPACE} + "${OPERATOR_REPO}"/olm/testUpdate.sh -p openshift -c stable -i quay.io/eclipse/eclipse-che-openshift-opm-catalog:test -n ${NAMESPACE} waitEclipseCheDeployed ${LAST_PACKAGE_VERSION} provisionOAuth startNewWorkspace diff --git a/.github/bin/common.sh b/.github/bin/common.sh index cd9401729a..fd8fbbe8cb 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -202,10 +202,14 @@ collectDevworkspaceOperatorLogs() { # Build latest operator image buildCheOperatorImage() { - #docker build -t "${OPERATOR_IMAGE}" -f Dockerfile . docker build -t "${OPERATOR_IMAGE}" -f Dockerfile . && docker save "${OPERATOR_IMAGE}" > /tmp/operator.tar } +buildAndPushCheOperatorImage() { + docker build -t "${OPERATOR_IMAGE}" -f Dockerfile . && docker push "${OPERATOR_IMAGE}" +} + + copyCheOperatorImageToMinikube() { #docker save "${OPERATOR_IMAGE}" | minikube ssh --native-ssh=false -- docker load eval $(minikube docker-env) && docker load -i /tmp/operator.tar && rm /tmp/operator.tar @@ -408,11 +412,6 @@ enableImagePuller() { kubectl patch checluster/eclipse-che -n ${NAMESPACE} --type=merge -p '{"spec":{"imagePuller":{"enable": true}}}' } -insecurePrivateDockerRegistry() { - IMAGE_REGISTRY_HOST="127.0.0.1:5000" - export IMAGE_REGISTRY_HOST -} - # Utility to print objects created by Openshift CI automatically printOlmCheObjects() { echo -e "[INFO] Operator Group object created in namespace: ${NAMESPACE}" diff --git a/.github/bin/minikube/test-olm.sh b/.github/bin/minikube/test-olm.sh index 0f1d10af5f..fadcf85bf1 100755 --- a/.github/bin/minikube/test-olm.sh +++ b/.github/bin/minikube/test-olm.sh @@ -27,13 +27,24 @@ source "${OPERATOR_REPO}/olm/olm.sh" trap "catchFinish" EXIT SIGINT runTest() { - local channel=next + local channel + local catalogImage + if [[ $GITHUB_HEAD_REF =~ release$ ]]; then channel=stable + catalogImage=quay.io/eclipse/eclipse-che-kubernetes-opm-catalog:test + else + # build operator image and push to a local docker registry + export OPERATOR_IMAGE="127.0.0.1:5000/test/operator:test" + buildAndPushCheOperatorImage + + # build catalog source + channel=next + catalogImage=127.0.0.1:5000/test/catalog:test + "${OPERATOR_REPO}"/olm/buildCatalog.sh -p kubernetes -c next -i ${catalogImage} -o ${OPERATOR_IMAGE} fi - export OPERATOR_IMAGE="${IMAGE_REGISTRY_HOST}/operator:test" - source "${OPERATOR_REPO}"/olm/testCatalogSource.sh "kubernetes" ${channel} "${NAMESPACE}" + source "${OPERATOR_REPO}"/olm/testCatalog.sh -p kubernetes -c ${channel} -n ${NAMESPACE} -i ${catalogImage} startNewWorkspace waitWorkspaceStart @@ -54,6 +65,4 @@ runTest() { } initDefaults -installOperatorMarketPlace -insecurePrivateDockerRegistry runTest diff --git a/.github/bin/minikube/test-stable-olm-update.sh b/.github/bin/minikube/test-stable-olm-update.sh index 47c2dc412d..176461a5da 100755 --- a/.github/bin/minikube/test-stable-olm-update.sh +++ b/.github/bin/minikube/test-stable-olm-update.sh @@ -22,7 +22,7 @@ source "${OPERATOR_REPO}"/.github/bin/common.sh trap "catchFinish" EXIT SIGINT runTest() { - "${OPERATOR_REPO}"/olm/testUpdate.sh "kubernetes" "stable" ${NAMESPACE} + "${OPERATOR_REPO}"/olm/testUpdate.sh -p kubernetes -c stable -i quay.io/eclipse/eclipse-che-kubernetes-opm-catalog:test -n ${NAMESPACE} waitEclipseCheDeployed ${LAST_PACKAGE_VERSION} startNewWorkspace waitWorkspaceStart diff --git a/.github/bin/recovery-olm-channels.sh b/.github/bin/recovery-olm-channels.sh deleted file mode 100755 index 8960d72506..0000000000 --- a/.github/bin/recovery-olm-channels.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2019-2021 Red Hat, Inc. -# This program and the accompanying materials are made -# available under the terms of the Eclipse Public License 2.0 -# which is available at https://www.eclipse.org/legal/epl-2.0/ -# -# SPDX-License-Identifier: EPL-2.0 -# -# Contributors: -# Red Hat, Inc. - initial API and implementation -# - -if [ -n "${GITHUB_WORKSPACE}" ]; then - ROOT_PROJECT_DIR="${GITHUB_WORKSPACE}" -else - SCRIPT=$(readlink -f "${BASH_SOURCE[0]}") - ROOT_PROJECT_DIR=$(dirname $(dirname "$(dirname "$SCRIPT")")) -fi - -if [ -z "${IMAGE_REGISTRY_HOST}" ] || [ -z "${IMAGE_REGISTRY_USER_NAME}" ]; then - echo "[ERROR] Specify env variables with information about image registry 'IMAGE_REGISTRY_HOST' and 'IMAGE_REGISTRY_USER_NAME'." - exit 1 -fi - -source "${BASE_DIR}/olm.sh" -installOPM -${OPM_BINARY} version - -for platform in 'openshift' 'kubernetes'; do - echo "Recovery OLM channels for ${platform}" - - CATALOG_BUNDLE_IMAGE="${IMAGE_REGISTRY_HOST}/${IMAGE_REGISTRY_USER_NAME}/eclipse-che-${platform}-opm-bundles" - echo "[INFO] Bundle image without tag: ${CATALOG_BUNDLE_IMAGE}" - - declare -a BUNDLE_TAGS=($(skopeo list-tags docker://${CATALOG_BUNDLE_IMAGE} 2>/dev/null | jq -r ".Tags[] | @sh")) - BUNDLE_IMAGES="" - for tag in "${BUNDLE_TAGS[@]}"; do - tag=$(echo "${tag}" | tr -d "'") - BUNDLE_IMAGES="${BUNDLE_IMAGES},${CATALOG_BUNDLE_IMAGE}:${tag}" - done - # Remove first coma - BUNDLE_IMAGES="${BUNDLE_IMAGES#,}" - - echo "[INFO] List bundle images: ${BUNDLE_IMAGES}" - # Rebuild and push index image with all found bundles. - INDEX_IMG="${IMAGE_REGISTRY_HOST}/${IMAGE_REGISTRY_USER_NAME}/eclipse-che-${platform}-opm-catalog:preview" - echo "[INFO] Rebuild and push catalog source image: " - echo "[INFO] ====================================== " - pushd "${ROOT_PROJECT_DIR}" || true - make catalog-build BUNDLE_IMGS="${BUNDLE_IMAGES}" CATALOG_IMG="${INDEX_IMG}" - make catalog-push CATALOG_IMG="${INDEX_IMG}" - popd || true -done diff --git a/.github/workflows/build-catalog-and-bundle-images.yaml b/.github/workflows/build-catalog-and-bundle-images.yaml index cfaa56dd35..4768cc5f05 100644 --- a/.github/workflows/build-catalog-and-bundle-images.yaml +++ b/.github/workflows/build-catalog-and-bundle-images.yaml @@ -37,10 +37,18 @@ jobs: username: ${{ secrets.QUAY_USERNAME }} password: ${{ secrets.QUAY_PASSWORD }} - name: Build and push images to quay.io - run: > - ${GITHUB_WORKSPACE}/olm/buildAndPushBundleImages.sh -c 'next' -p 'openshift' && - ${GITHUB_WORKSPACE}/olm/buildAndPushBundleImages.sh -c 'next-all-namespaces' -p 'openshift' && - ${GITHUB_WORKSPACE}/olm/buildAndPushBundleImages.sh -c 'next' -p 'kubernetes' - env: - IMAGE_REGISTRY_HOST: quay.io - IMAGE_REGISTRY_USER_NAME: eclipse + run: | + ${GITHUB_WORKSPACE}/olm/buildCatalog.sh \ + --channel 'next' \ + --platform 'openshift' \ + --catalog-image quay.io/eclipse/eclipse-che-openshift-opm-catalog:next + + ${GITHUB_WORKSPACE}/olm/buildCatalog.sh \ + --channel 'next' \ + --platform 'kubernetes' \ + --catalog-image quay.io/eclipse/eclipse-che-kubernetes-opm-catalog:next + + ${GITHUB_WORKSPACE}/olm/buildCatalog.sh \ + --channel 'next-all-namespaces' \ + --platform 'openshift' \ + --catalog-image quay.io/eclipse/eclipse-che-openshift-opm-catalog:next diff --git a/.github/workflows/minikube-olm.yaml b/.github/workflows/minikube-olm.yaml index 04a5224f4c..3dc00f1ed0 100644 --- a/.github/workflows/minikube-olm.yaml +++ b/.github/workflows/minikube-olm.yaml @@ -29,7 +29,7 @@ jobs: run: | minikube addons enable ingress - # Enable registry and portfward to push images to registry + # Enable registry and port forward to push images to registry /bin/bash olm/minikube-registry-addon.sh & - name: Install chectl run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next diff --git a/.github/workflows/recovery-index-images.yaml b/.github/workflows/recovery-index-images.yaml deleted file mode 100644 index 90242132f6..0000000000 --- a/.github/workflows/recovery-index-images.yaml +++ /dev/null @@ -1,40 +0,0 @@ -# -# Copyright (c) 2019-2021 Red Hat, Inc. -# This program and the accompanying materials are made -# available under the terms of the Eclipse Public License 2.0 -# which is available at https://www.eclipse.org/legal/epl-2.0/ -# -# SPDX-License-Identifier: EPL-2.0 -# -# Contributors: -# Red Hat, Inc. - initial API and implementation -# - -name: Recovery OLM channels in the index images -on: - # manual trigger if required - workflow_dispatch: - inputs: - reason: - description: 'Reason to trigger index images recovery' - required: false -jobs: - build-images: - name: Build - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v1 - - name: Install yq - run: sudo pip install yq - - name: Docker login - uses: azure/docker-login@v1 - with: - login-server: quay.io - username: ${{ secrets.QUAY_USERNAME }} - password: ${{ secrets.QUAY_PASSWORD }} - - name: Build and push images to quay.io - run: > - ${GITHUB_WORKSPACE}/.github/bin/recovery-olm-channels.sh - env: - IMAGE_REGISTRY_HOST: quay.io - IMAGE_REGISTRY_USER_NAME: eclipse diff --git a/.vscode/launch.json b/.vscode/launch.json index ab717db482..cebdde6754 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -27,50 +27,69 @@ { "type": "bashdb", "request": "launch", - "name": "Bash-Debug (testCatalogSource.sh) minikube stable", + "name": "Bash-Debug (testCatalog.sh) minikube stable", "cwd": "${workspaceFolder}/olm", - "program": "${workspaceFolder}/olm/testCatalogSource.sh", + "program": "${workspaceFolder}/olm/testCatalog.sh", "args": [ + "-p", "kubernetes", + "-c", "stable", - "che", + "-i", + "quay.io/eclipse/eclipse-che-kubernetes-opm-catalog:test", + "-n", + "eclipse-che", ] }, { "type": "bashdb", "request": "launch", - "name": "Bash-Debug (testCatalogSource.sh) minikube next", + "name": "Bash-Debug (testCatalog.sh) minikube next", "cwd": "${workspaceFolder}/olm", - "program": "${workspaceFolder}/olm/testCatalogSource.sh", + "program": "${workspaceFolder}/olm/testCatalog.sh", "args": [ + "-p", "kubernetes", + "-c", "next", - "che", - "my_catalog" + "-i", + "quay.io/eclipse/eclipse-che-kubernetes-opm-catalog:next", + "-n", + "eclipse-che", ] }, { "type": "bashdb", "request": "launch", - "name": "Bash-Debug (testCatalogSource.sh) openshift next", + "name": "Bash-Debug (testCatalog.sh) openshift next", "cwd": "${workspaceFolder}", - "program": "${workspaceFolder}/olm/testCatalogSource.sh", + "program": "${workspaceFolder}/olm/testCatalog.sh", "args": [ + "-p", "openshift", + "-c", "next", - "che" + "-i", + "quay.io/eclipse/eclipse-che-openshift-opm-catalog:next", + "-n", + "eclipse-che", ] }, { "type": "bashdb", "request": "launch", - "name": "Bash-Debug (testCatalogSource.sh) openshift stable", + "name": "Bash-Debug (testCatalog.sh) openshift stable", "cwd": "${workspaceFolder}", - "program": "${workspaceFolder}/olm/testCatalogSource.sh", + "program": "${workspaceFolder}/olm/testCatalog.sh", "args": [ + "-p", "openshift", + "-c", "stable", - "che" + "-i", + "quay.io/eclipse/eclipse-che-openshift-opm-catalog:test", + "-n", + "eclipse-che", ] }, { @@ -80,9 +99,14 @@ "cwd": "${workspaceFolder}/olm", "program": "${workspaceFolder}/olm/testUpdate.sh", "args": [ + "-p", "kubernetes", + "-c", "stable", - "che" + "-i", + "quay.io/eclipse/eclipse-che-kubernetes-opm-catalog:test", + "-n", + "eclipse-che" ] }, { @@ -92,9 +116,14 @@ "cwd": "${workspaceFolder}/olm", "program": "${workspaceFolder}/olm/testUpdate.sh", "args": [ + "-p", "kubernetes", + "-c", "next", - "che" + "-i", + "quay.io/eclipse/eclipse-che-kubernetes-opm-catalog:next", + "-n", + "eclipse-che" ] }, { @@ -104,9 +133,14 @@ "cwd": "${workspaceFolder}/olm", "program": "${workspaceFolder}/olm/testUpdate.sh", "args": [ + "-p", "openshift", + "-c", "stable", - "che" + "-i", + "quay.io/eclipse/eclipse-che-openshift-opm-catalog:test", + "-n", + "eclipse-che" ] }, { @@ -116,35 +150,44 @@ "cwd": "${workspaceFolder}/olm", "program": "${workspaceFolder}/olm/testUpdate.sh", "args": [ + "-p", "openshift", + "-c", "next", - "che" + "-i", + "quay.io/eclipse/eclipse-che-openshift-opm-catalog:next", + "-n", + "eclipse-che" ] }, { "type": "bashdb", "request": "launch", - "name": "Bash-Debug (buildAndPushBundleImages.sh) Kubernetes platfrom", + "name": "Bash-Debug (buildCatalog.sh) Kubernetes platfrom", "cwd": "${workspaceFolder}/olm", - "program": "./buildAndPushBundleImages.sh", + "program": "./buildCatalog.sh", "args": [ "-p", "kubernetes", "-c", - "next" + "next", + "-i", + "quay.io/eclipse/eclipse-che-kubernetes-opm-catalog:next" ] }, { "type": "bashdb", "request": "launch", - "name": "Bash-Debug (buildAndPushBundleImages.sh) Openshift platform", + "name": "Bash-Debug (buildCatalog.sh) Openshift platform", "cwd": "${workspaceFolder}/olm", - "program": "./buildAndPushBundleImages.sh", + "program": "./buildCatalog.sh", "args": [ "-p", "openshift", "-c", - "next" + "next", + "-i", + "quay.io/eclipse/eclipse-che-openshift-opm-catalog:next" ] }, { diff --git a/README.md b/README.md index 1e7f234bd3..4d82da145b 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ $ make update-resources -s 3. Build catalog source and bundle images: ```bash -$ olm/buildAndPushBundleImages.sh -p -c "next" +$ olm/buildCatalog.sh -p -c -i ``` 4. Create a custom catalog source yaml (update strategy is workaround for https://github.com/operator-framework/operator-lifecycle-manager/issues/903): @@ -121,10 +121,10 @@ $ olm/buildAndPushBundleImages.sh -p -c "next" apiVersion: operators.coreos.com/v1alpha1 kind: CatalogSource metadata: - name: eclipse-che-preview-custom - namespace: che-namespace + name: eclipse-che-custom-catalog + namespace: eclipse-che spec: - image: //eclipse-che--opm-catalog:preview + image: sourceType: grpc updateStrategy: registryPoll: @@ -135,7 +135,7 @@ spec: ```bash -$ chectl server:deploy --installer=olm --platform= --catalog-source-yaml --olm-channel=next --package-manifest-name=eclipse-che-preview- +$ chectl server:deploy --installer=olm --platform= --catalog-source-yaml --olm-channel=next --package-manifest-name=eclipse-che-preview- ``` ### Deploy stable Che operator in Cluster Wide Availability diff --git a/RELEASE.md b/RELEASE.md index 9599d3d586..bc98260ce1 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -34,7 +34,7 @@ To be able to test update it is needed to created some user before. Login as `ku ```bash cd olm -./testUpdate.sh openshift stable +./testUpdate.sh -p openshift -c stable -i quay.io/eclipse/eclipse-che-openshift-opm-catalog:test -n eclipse-che ``` Open Eclipse Che dashboard in an anonymous tab: @@ -54,7 +54,7 @@ Run script to test updates: ```bash cd olm -./testUpdate.sh kubernetes stable +./testUpdate.sh -p kubernetes -c stable -i quay.io/eclipse/eclipse-che-kubernetes-opm-catalog:test -n eclipse-che ``` Open Eclipse Che dashboard: diff --git a/make-release.sh b/make-release.sh index 8cec381657..082c1ee830 100755 --- a/make-release.sh +++ b/make-release.sh @@ -248,9 +248,10 @@ pushOlmBundlesToQuayIo() { echo "[INFO] releaseOperatorCode :: Login to quay.io..." docker login quay.io -u "${QUAY_ECLIPSE_CHE_USERNAME}" -p "${QUAY_ECLIPSE_CHE_PASSWORD}" echo "[INFO] Push OLM bundles to quay.io" - . ${RELEASE_DIR}/olm/buildAndPushBundleImages.sh -c "tech-preview-stable-all-namespaces" -p "openshift" -f "true" - . ${RELEASE_DIR}/olm/buildAndPushBundleImages.sh -c "stable" -p "kubernetes" -f "true" - . ${RELEASE_DIR}/olm/buildAndPushBundleImages.sh -c "stable" -p "openshift" -f "true" + + . ${RELEASE_DIR}/olm/buildCatalog.sh -c tech-preview-stable-all-namespaces -p openshift -i quay.io/eclipse/eclipse-che-openshift-opm-catalog:test -f + . ${RELEASE_DIR}/olm/buildCatalog.sh -c stable -p kubernetes -i quay.io/eclipse/eclipse-che-kubernetes-opm-catalog:test -f + . ${RELEASE_DIR}/olm/buildCatalog.sh -c stable -p openshift -i quay.io/eclipse/eclipse-che-openshift-opm-catalog:test -f } pushGitChanges() { diff --git a/olm/README.md b/olm/README.md index 00e429a671..9cfaa85351 100644 --- a/olm/README.md +++ b/olm/README.md @@ -25,8 +25,8 @@ Each bundle consists of a cluster service version file (CSV) and a custom resour To test next Che operator you have to use the OLM CatalogSource(index) image. CatalogSource image stores in the internal database information about OLM bundles with different versions of the Eclipse Che. For next channel (dependent on platform) Eclipse Che provides two CatalogSource images: - - `quay.io/eclipse/eclipse-che-kubernetes-opm-catalog:preview` for Kubernetes platform; - - `quay.io/eclipse/eclipse-che-openshift-opm-catalog:preview` for Openshift platform; + - `quay.io/eclipse/eclipse-che-kubernetes-opm-catalog:next` for Kubernetes platform; + - `quay.io/eclipse/eclipse-che-openshift-opm-catalog:next` for Openshift platform; For each new next version Eclipse Che provides next bundle image with name pattern: @@ -42,25 +42,13 @@ quay.io/eclipse/eclipse-che-openshift-opm-bundles:7.19.0-5.next ### Build custom next/stable OLM images For test purpose you can build your own "next" or "stable" CatalogSource and bundle images -with your latest development changes and use it in the test scripts. To build these images you can use script `olm/buildAndPushBundleImages.sh`: +with your latest development changes and use it in the test scripts. To build these images you can use script `olm/buildCatalog.sh`: ```bash -$ export IMAGE_REGISTRY_USER_NAME= && \ - export IMAGE_REGISTRY_HOST= && \ - ./buildAndPushBundleImages.sh -p -c -i -``` - -This script will build and push for you two images: CatalogSource(index) and bundle one: - -* `${IMAGE_REGISTRY_HOST}/${IMAGE_REGISTRY_USER_NAME}/eclipse-che--opm-bundles:-.next` -* `${IMAGE_REGISTRY_HOST}/${IMAGE_REGISTRY_USER_NAME}/eclipse-che--opm-catalog:preview` - -CatalogSource images are additive. It's mean that you can re-use bundles from another CatalogSource image and include them to your custom CatalogSource image. For this purpose you can specify the parameter `-i`: - -```bash -$ export IMAGE_REGISTRY_USER_NAME= && \ - export IMAGE_REGISTRY_HOST= && \ - ./buildAndPushBundleImages.sh -p -n -i +$ olm/buildCatalog.sh \ + -c (next|next-all-namespaces|stable|tech-preview-all-namespaces) \ + -p (openshift|kubernetes) \ + -i ``` ### Testing custom CatalogSource and bundle images on the Openshift @@ -68,21 +56,13 @@ $ export IMAGE_REGISTRY_USER_NAME= && \ To test the latest custom "next" bundle: ```bash -$ ./testCatalogSource.sh "openshift" "next" +$ ./testCatalog.sh -p openshift -c next -i -n eclipse-che ``` If your CatalogSource image contains few bundles, you can test migration from previous bundle to the latest: ```bash -$ export IMAGE_REGISTRY_USER_NAME= && \ - export IMAGE_REGISTRY_HOST= && \ - ./testUpdate.sh "openshift" "next" -``` - -Note, to test your own operator image, it must be defined in `OPERATOR_IMAGE` environment variable before running `testCatalogSource.sh` script, for example: - -```bash -export OPERATOR_IMAGE=registry/account/che-operator:tag +$ ./testUpdate.sh -p openshift -c next -i -n eclipse-che ``` ### Testing custom CatalogSource and bundle images on the Kubernetes @@ -92,17 +72,13 @@ To test your custom CatalogSource and bundle images on the Kubernetes you need t To test the latest custom "next" bundle: ```bash -$ export IMAGE_REGISTRY_USER_NAME= && \ - export IMAGE_REGISTRY_HOST= && \ - ./testCatalogSource.sh "kubernetes" "next" +$ ./testCatalog.sh -p kubernetes -c next -i -n eclipse-che ``` If your CatalogSource image contains few bundles, you can test migration from previous bundle to the latest: ```bash -$ export IMAGE_REGISTRY_USER_NAME= && \ - export IMAGE_REGISTRY_HOST= && \ - ./testUpdate.sh "kubernetes" "next" +$ ./testUpdate.sh -p kubernetes -c next -i -n eclipse-che ``` Also you can test your changes without a public registry. You can use the minikube cluster and enable the minikube "registry" addon. For this purpose use the script: @@ -121,9 +97,8 @@ $ curl -X GET localhost:5000/v2/_catalog With this private registry you can test Che operator from development bundle: ```bash -$ export IMAGE_REGISTRY_HOST="127.0.0.1:5000" && \ - export IMAGE_REGISTRY_USER_NAME="" && \ - ./testCatalogSource.sh "kubernetes" "next" +$ olm/buildCatalog.sh -p kubernetes -c next -i 127.0.0.1:5000/test/catalog:test +$ olm/testCatalog.sh -p kubernetes -c next -i 127.0.0.1:5000/test/catalog:test -n eclipse-che ``` > Tips: If minikube was installed locally (driver 'none', local installation minikube), then registry is available on the host 0.0.0.0 without port forwarding but it requires `sudo`. @@ -143,7 +118,7 @@ metadata: name: eclipse-che-preview-custom namespace: spec: - image: quay.io/eclipse/eclipse-che--opm-catalog:preview + image: quay.io/eclipse/eclipse-che--opm-catalog:test sourceType: grpc updateStrategy: registryPoll: diff --git a/olm/buildAndPushBundleImages.sh b/olm/buildAndPushBundleImages.sh deleted file mode 100755 index c999360c12..0000000000 --- a/olm/buildAndPushBundleImages.sh +++ /dev/null @@ -1,108 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2019-2021 Red Hat, Inc. -# This program and the accompanying materials are made -# available under the terms of the Eclipse Public License 2.0 -# which is available at https://www.eclipse.org/legal/epl-2.0/ -# -# SPDX-License-Identifier: EPL-2.0 -# -# Contributors: -# Red Hat, Inc. - initial API and implementation -# - -set -ex - -usage () { - echo "Usage: $0 -p [platform] -c [channel] -i [from-index-image(optional)] -f [force-build-and-push(optional)]" - echo "Example: $0 -p openshift -c next -i quay.io/eclipse/eclipse-che-openshift-opm-catalog:preview -f true" -} - -if [[ $# -lt 1 ]]; then usage; exit; fi - -unset channel platform forceBuildAndPush fromIndexImage - -while [[ "$#" -gt 0 ]]; do - case $1 in - '-c') channel="$2"; shift 1;; - '-p') platform="$2"; shift 1;; - '-f') forceBuildAndPush="$2"; shift 1;; - '-i') fromIndexImage="$2"; shift 1;; - '--help'|'-h') usage; exit;; - esac - shift 1 -done - -if [[ ! ${channel} ]] || [[ ! ${platform} ]]; then usage; exit 1; fi - -if [ -z "${forceBuildAndPush}" ]; then - forceBuildAndPush="false" -fi -if [ ! "${forceBuildAndPush}" == "true" ] && [ ! "${forceBuildAndPush}" == "false" ]; then - echo "[ERROR] -f argument should be 'true' or 'false'" - exit 1 -fi - -if [ -z "${IMAGE_REGISTRY_HOST}" ] || [ -z "${IMAGE_REGISTRY_USER_NAME}" ]; then - echo "[ERROR] Specify env variables with information about image registry 'IMAGE_REGISTRY_HOST' and 'IMAGE_REGISTRY_USER_NAME'." - exit 1 -fi - -if [ -n "${GITHUB_WORKSPACE}" ]; then - ROOT_PROJECT_DIR="${GITHUB_WORKSPACE}" -else - SCRIPT=$(readlink -f "${BASH_SOURCE[0]}") - ROOT_PROJECT_DIR=$(dirname "$(dirname "$SCRIPT")") -fi - -export BASE_DIR="${ROOT_PROJECT_DIR}/olm" - -source "${BASE_DIR}/olm.sh" -installOPM -${OPM_BINARY} version - -echo "[INFO] Platform: ${platform}" -if [ -n "${OPM_BUNDLE_DIR}" ]; then - bundleDir="${OPM_BUNDLE_DIR}" -else - bundleDir=$(getBundlePath "${platform}" "${channel}") -fi -OPM_BUNDLE_MANIFESTS_DIR="${bundleDir}/manifests" -CSV="${OPM_BUNDLE_MANIFESTS_DIR}/che-operator.clusterserviceversion.yaml" - -BUNDLE_TAG=$(yq -r ".spec.version" "${CSV}") -echo "[INFO] Bundle version and tag: ${BUNDLE_TAG}" - -CATALOG_BUNDLE_IMAGE="${IMAGE_REGISTRY_HOST}/${IMAGE_REGISTRY_USER_NAME}/eclipse-che-${platform}-opm-bundles:${BUNDLE_TAG}" -CATALOG_TAG="preview" -CATALOG_IMAGE="${IMAGE_REGISTRY_HOST}/${IMAGE_REGISTRY_USER_NAME}/eclipse-che-${platform}-opm-catalog:${CATALOG_TAG}" - -# Validate and set up ${fromIndexImage} argument -if [ -n "${fromIndexImage}" ]; then - INDEX_CATALOG_EXISTS=$(skopeo inspect docker://${fromIndexImage} 2>/dev/null | jq -r ".RepoTags[]") - if [ -z "${INDEX_CATALOG_EXISTS}" ]; then - echo "[ERROR] 'from' index image ${fromIndexImage} is not avaliable in the image registry." - exit 1 - fi -else - CATALOG_EXISTS=$(skopeo inspect docker://${CATALOG_IMAGE} 2>/dev/null | jq -r ".RepoTags[]") - if [ -n "${CATALOG_EXISTS}" ]; then - echo "[INFO] Set up 'from' index image argument: ${CATALOG_IMAGE} to save previous bundles." - fromIndexImage="${CATALOG_IMAGE}" - fi -fi - -CHECK_BUNDLE_TAG=$(skopeo inspect docker://${CATALOG_BUNDLE_IMAGE} 2>/dev/null | jq -r ".RepoTags[]|select(. == \"${BUNDLE_TAG}\")") -if [[ -z "$CHECK_BUNDLE_TAG" ]] || [[ "${forceBuildAndPush}" == "true" ]]; then - buildBundleImage "${platform}" "${CATALOG_BUNDLE_IMAGE}" "${channel}" "docker" - - if [ -n "${fromIndexImage}" ]; then - buildCatalogImage "${CATALOG_IMAGE}" "${CATALOG_BUNDLE_IMAGE}" "docker" "${forceBuildAndPush}" "${fromIndexImage}" - else - buildCatalogImage "${CATALOG_IMAGE}" "${CATALOG_BUNDLE_IMAGE}" "docker" "${forceBuildAndPush}" - fi -else - echo "[WARN] Bundle ${CATALOG_BUNDLE_IMAGE} is already pushed to the image registry. Rebuild bundle and catalog source images was skipped. Use '-f true' argument to force it." -fi - -echo "[INFO] Done." diff --git a/olm/buildCatalog.sh b/olm/buildCatalog.sh new file mode 100755 index 0000000000..870419d122 --- /dev/null +++ b/olm/buildCatalog.sh @@ -0,0 +1,112 @@ +#!/bin/bash +# +# Copyright (c) 2019-2021 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Red Hat, Inc. - initial API and implementation +# + +set -e + +export OPERATOR_REPO="${GITHUB_WORKSPACE}" + +if [ -z "${OPERATOR_REPO}" ]; then + SCRIPT=$(readlink -f "${BASH_SOURCE[0]}") + OPERATOR_REPO=$(dirname "$(dirname "$SCRIPT")") +fi +source "${OPERATOR_REPO}"/olm/olm.sh + +init() { + FORCE="false" + unset CHANNEL + unset PLATFORM + unset CATALOG_IMAGE + unset OPERATOR_IMAGE + + while [[ "$#" -gt 0 ]]; do + case $1 in + '--channel'|'-c') CHANNEL="$2"; shift 1;; + '--platform'|'-p') PLATFORM="$2"; shift 1;; + '--catalog-image'|'-i') CATALOG_IMAGE="$2"; shift 1;; + '--operator-image'|'-o') OPERATOR_IMAGE="$2"; shift 1;; + '--force'|'-f') FORCE="true";; + '--help'|'-h') usage; exit;; + esac + shift 1 + done + + if [[ ! ${CHANNEL} ]] || [[ ! ${PLATFORM} ]] || [[ ! ${CATALOG_IMAGE} ]]; then usage; exit 1; fi + + BUNDLE_DIR=$(getBundlePath "${PLATFORM}" "${CHANNEL}") + OPM_BUNDLE_MANIFESTS_DIR="${BUNDLE_DIR}/manifests" + CSV="${OPM_BUNDLE_MANIFESTS_DIR}/che-operator.clusterserviceversion.yaml" + CSV_NAME=$(yq -r ".metadata.name" "${CSV}") + CSV_VERSION=$(yq -r ".spec.version" "${CSV}") + + IMAGE_REGISTRY_HOST=$(echo ${CATALOG_IMAGE} | cut -d '/' -f1) + IMAGE_REGISTRY_USER_NAME=$(echo ${CATALOG_IMAGE} | cut -d '/' -f2) + BUNDLE_IMAGE="${IMAGE_REGISTRY_HOST}/${IMAGE_REGISTRY_USER_NAME}/eclipse-che-${PLATFORM}-opm-bundles:${CSV_VERSION}" + + echo "[INFO] CSV: ${CSV}" + echo "[INFO] CSV name: ${CSV_NAME}" + echo "[INFO] CSV version: ${CSV_VERSION}" + echo "[INFO] Bundle image: ${BUNDLE_IMAGE}" + + if [[ ! -z ${OPERATOR_IMAGE} ]]; then + # set a given operator image into CSV before build + sed -e "s|image:.*|image: ${OPERATOR_IMAGE}|" -i "${CSV}" + fi +} + +usage () { + echo "Usage: $0 -p (openshift|kubernetes) -c (next|next-all-namespaces|stable|tech-preview-all-namespaces) -i CATALOG_IMAGE [-f]" + echo "Example: $0 -p openshift -c next -i quay.io/eclipse/eclipse-che-openshift-opm-catalog:next -f" +} + +buildBundle() { + if [[ $(isBundleImageExists) == 0 ]] || [[ "${FORCE}" == "true" ]]; then + echo "[INFO] Build bundle image" + buildBundleImage "${PLATFORM}" "${BUNDLE_IMAGE}" "${CHANNEL}" "docker" + else + echo "[INFO] Bundle image already exists. Use '--force' flag to force build." + fi +} + +buildCatalog () { + if [ $(isCatalogExists) == 0 ]; then + echo "[INFO] Bundle a new catalog" + buildCatalogImage "${CATALOG_IMAGE}" "${BUNDLE_IMAGE}" "docker" "${FORCE}" + else + if [[ $(isBundleExistsInCatalog) == 0 ]]; then + echo "[INFO] Add a new bundle ${CSV_NAME} to the catalog" + buildCatalogImage "${CATALOG_IMAGE}" "${BUNDLE_IMAGE}" "docker" "${FORCE}" "${CATALOG_IMAGE}" + else + echo "[INFO] Bundle ${CSV_NAME} already exists in the catalog" + fi + fi +} + +isBundleExistsInCatalog() { + docker run -ti --entrypoint sh ${CATALOG_IMAGE} -c "apk add sqlite && sqlite3 /database/index.db 'SELECT head_operatorbundle_name FROM channel WHERE name = \"next\" and head_operatorbundle_name = \"${CSV_NAME}\"'" AND | tail -n1 | wc -l +} + +isBundleImageExists() { + skopeo inspect docker://${BUNDLE_IMAGE} 2>/dev/null | jq -r ".RepoTags[]|select(. == \"${CSV_VERSION}\")" | wc -l +} + +isCatalogExists() { + CATALOG_TAG=$(echo $CATALOG_IMAGE | rev | cut -d ':' -f1 | rev) + skopeo inspect docker://${CATALOG_IMAGE} 2>/dev/null | jq -r ".RepoTags[]|select(. == \"${CATALOG_TAG}\")" | wc -l +} + +init $@ +installOPM +buildBundle +buildCatalog + +echo "[INFO] Done" diff --git a/olm/olm.sh b/olm/olm.sh index b1fc9e0ab4..1cd91797b8 100755 --- a/olm/olm.sh +++ b/olm/olm.sh @@ -248,6 +248,7 @@ installOPM() { chmod +x "${OPM_BINARY}" echo "[INFO] Downloading completed!" echo "[INFO] 'opm' binary path: ${OPM_BINARY}" + ${OPM_BINARY} version popd || exit fi } @@ -403,35 +404,25 @@ installPackage() { fi } -applyCRCheCluster() { - platform="${1}" - if [ -z "${platform}" ]; then - echo "[ERROR] Please specify first argument: 'platform'" - exit 1 - fi - namespace="${2}" - if [ -z "${namespace}" ]; then - echo "[ERROR] Please specify second argument: 'namespace'" - exit 1 - fi - CSV_FILE="${3}" - if [ -z "${CSV_FILE}" ]; then - echo "[ERROR] Please specify third argument: 'CSV_FILE'" - exit 1 - fi +applyCheClusterCR() { + CSV_NAME=${1} + PLATFORM=${2} - echo "[INFO] Creating Custom Resource" + CHECLUSTER=$(kubectl get csv ${CSV_NAME} -n ${NAMESPACE} -o yaml \ + | yq -r ".metadata.annotations[\"alm-examples\"] | fromjson | .[] | select(.kind == \"CheCluster\")" \ + | yq -r ".spec.devWorkspace.enable = ${DEV_WORKSPACE_ENABLE:-false}" \ + | yq -r ".spec.server.serverExposureStrategy = \"${CHE_EXPOSURE_STRATEGY:-multi-host}\"" \ + | yq -r ".spec.imagePuller.enable = ${IMAGE_PULLER_ENABLE:-false}") - CR=$(yq -r ".metadata.annotations[\"alm-examples\"] | fromjson | .[] | select(.kind == \"CheCluster\")" "${CSV_FILE}") - CR=$(echo "$CR" | yq -r ".spec.devWorkspace.enable = ${DEV_WORKSPACE_ENABLE:-false}") - CR=$(echo "$CR" | yq -r ".spec.server.serverExposureStrategy = \"${CHE_EXPOSURE_STRATEGY:-multi-host}\"") - CR=$(echo "$CR" | yq -r ".spec.server.imagePuller.enable = ${IMAGE_PULLER_ENABLE:-false}") - if [ "${platform}" == "kubernetes" ] - then - CR=$(echo "$CR" | yq -r ".spec.k8s.ingressDomain = \"$(minikube ip).nip.io\"") + echo "${CHECLUSTER}" + if [[ ${PLATFORM} == "kubernetes" ]]; then + CHECLUSTER=$(echo "${CHECLUSTER}" | yq -r ".spec.k8s.ingressDomain = \"$(minikube ip).nip.io\"") fi - echo "$CR" | kubectl apply -n "${namespace}" --validate=false -f - + echo "[INFO] Creating Custom Resource: " + echo "${CHECLUSTER}" + + echo "${CHECLUSTER}" | kubectl apply -n $NAMESPACE -f - } waitCheServerDeploy() { @@ -465,6 +456,8 @@ waitCheServerDeploy() { } waitCatalogSourcePod() { + sleep 10s + CURRENT_TIME=$(date +%s) ENDTIME=$(($CURRENT_TIME + 300)) CATALOG_POD=$(kubectl get pods -n "${namespace}" -o yaml | yq -r ".items[] | select(.metadata.name | startswith(\"${packageName}\")) | .metadata.name") @@ -508,8 +501,6 @@ getBundleListFromCatalogSource() { ) LIST_BUNDLES=$(echo "${LIST_BUNDLES}" | head -n -1) - - echo "${LIST_BUNDLES}" } getPreviousCSVInfo() { diff --git a/olm/prepare-community-operators-update.sh b/olm/prepare-community-operators-update.sh index c2b92741b6..d15c1f8f81 100755 --- a/olm/prepare-community-operators-update.sh +++ b/olm/prepare-community-operators-update.sh @@ -69,7 +69,7 @@ getLatestsStableVersions for platform in $(echo $PLATFORMS | tr "," " ") do - INDEX_IMAGE="quay.io/eclipse/eclipse-che-${platform}-opm-catalog:preview" + INDEX_IMAGE="quay.io/eclipse/eclipse-che-${platform}-opm-catalog:test" packageName="eclipse-che-preview-${platform}" echo echo "## Prepare the OperatorHub package to push to the 'community-operators' repository for platform '${platform}' from local package '${packageName}'" @@ -97,7 +97,7 @@ do git remote remove upstream git remote add upstream https://github.com/redhat-openshift-ecosystem/community-operators-prod fi - + git fetch upstream ${base_branch}:upstream/${base_branch} branch="update-eclipse-che" diff --git a/olm/testCatalog.sh b/olm/testCatalog.sh new file mode 100755 index 0000000000..cb97039199 --- /dev/null +++ b/olm/testCatalog.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# +# Copyright (c) 2019-2021 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Red Hat, Inc. - initial API and implementation +# + +set -e + +export OPERATOR_REPO="${GITHUB_WORKSPACE}" + +if [ -z "${OPERATOR_REPO}" ]; then + SCRIPT=$(readlink -f "${BASH_SOURCE[0]}") + OPERATOR_REPO=$(dirname "$(dirname "$SCRIPT")") +fi +source "${OPERATOR_REPO}/olm/olm.sh" + +init() { + unset CHANNEL + unset PLATFORM + unset CATALOG_IMAGE + unset NAMESPACE + + while [[ "$#" -gt 0 ]]; do + case $1 in + '--channel'|'-c') CHANNEL="$2"; shift 1;; + '--platform'|'-p') PLATFORM="$2"; shift 1;; + '--namespace'|'-n') NAMESPACE="$2"; shift 1;; + '--catalog-image'|'-i') CATALOG_IMAGE="$2"; shift 1;; + '--help'|'-h') usage; exit;; + esac + shift 1 + done + + if [[ ! ${CHANNEL} ]] || [[ ! ${PLATFORM} ]] || [[ ! ${CATALOG_IMAGE} ]] || [[ ! ${NAMESPACE} ]]; then usage; exit 1; fi +} + +usage () { + echo "Usage: $0 -p (openshift|kubernetes) -c (next|next-all-namespaces|stable) -i CATALOG_IMAGE -n NAMESPACE" + echo "Example: $0 -p openshift -c next -i quay.io/eclipse/eclipse-che-openshift-opm-catalog:next -n eclipse-che" +} + +run() { + createNamespace ${NAMESPACE} + installOperatorMarketPlace + installCatalogSource "${PLATFORM}" "${NAMESPACE}" "${CATALOG_IMAGE}" + + getBundleListFromCatalogSource "${PLATFORM}" "${NAMESPACE}" + getLatestCSVInfo "${CHANNEL}" + + forcePullingOlmImages "${NAMESPACE}" "${LATEST_CSV_BUNDLE_IMAGE}" + + subscribeToInstallation "${PLATFORM}" "${NAMESPACE}" "${CHANNEL}" "${LATEST_CSV_NAME}" + installPackage "${PLATFORM}" "${NAMESPACE}" + + applyCheClusterCR ${LATEST_CSV_NAME} ${PLATFORM} + waitCheServerDeploy "${NAMESPACE}" +} + +init $@ +installOPM +run + +echo "[INFO] Done" + diff --git a/olm/testCatalogSource.sh b/olm/testCatalogSource.sh deleted file mode 100755 index f22052ded6..0000000000 --- a/olm/testCatalogSource.sh +++ /dev/null @@ -1,285 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2019-2021 Red Hat, Inc. -# This program and the accompanying materials are made -# available under the terms of the Eclipse Public License 2.0 -# which is available at https://www.eclipse.org/legal/epl-2.0/ -# -# SPDX-License-Identifier: EPL-2.0 -# -# Contributors: -# Red Hat, Inc. - initial API and implementation -# - -# bash ansi colors - -GREEN='\033[0;32m' -NC='\033[0m' - -readlink -f "$0" - -if [ -z "${OPERATOR_REPO}" ]; then - SCRIPT=$(readlink -f "$0") - - OPERATOR_REPO=$(dirname "$(dirname "$SCRIPT")"); -fi -echo "Operator repo path is ${OPERATOR_REPO}" - -OLM_DIR="${OPERATOR_REPO}/olm" -export OPERATOR_REPO - -# Function which will print all arguments need it to run this script -printHelp() { - echo '' - echo 'Please consider to pass this values to the script to run catalog source tests in your cluster:' - echo ' PLATFORM - Platform used to run olm files tests' - echo ' CHANNEL - Channel used to tests olm files' - echo ' NAMESPACE - Namespace where Eclipse Che will be deployed' - echo ' CATALOG_SOURCE_IMAGE - Image name used to create a catalog source in cluster' - echo '' - echo 'EXAMPLE of running: ${OPERATOR_REPO}/olm/testCatalogSource.sh openshift next che my_image_name' -} - -# Check if a platform was defined... -PLATFORM=$1 -if [ "${PLATFORM}" == "" ]; then - echo -e "${RED}[ERROR]: Please specify a valid platform. The posible platforms are kubernetes or openshift.The script will exit with code 1.${NC}" - printHelp - exit 1 -else - echo "[INFO]: Successfully validated platform. Starting olm tests in platform: ${PLATFORM}." -fi - -# Check if a channel was defined... The available channels are 'next' and 'stable' -CHANNEL=$2 -if [ "${CHANNEL}" == "stable" ] || [ "${CHANNEL}" == "next" ]; then - echo "[INFO]: Successfully validated operator channel. Starting olm tests in channel: ${CHANNEL}." -else - echo "[ERROR]: Please specify a valid channel. The posible 'channels' are stable and 'next'. The script will exit with code 1." - printHelp - exit 1 -fi - -# Check if a namespace was defined... -NAMESPACE=$3 -if [ "${NAMESPACE}" == "" ]; then - echo "[ERROR]: No namespace was specified... The script wil exit with code 1." - printHelp - exit 1 -else - echo "[INFO]: Successfully asigned namespace ${NAMESPACE} to tests olm files." -fi - -# Assign catalog source image -CATALOG_SOURCE_IMAGE=$4 - -IMAGE_REGISTRY_USER_NAME=${IMAGE_REGISTRY_USER_NAME:-eclipse} -echo "[INFO] Image 'IMAGE_REGISTRY_USER_NAME': ${IMAGE_REGISTRY_USER_NAME}" - -init() { - source "${OLM_DIR}/olm.sh" - OPM_BUNDLE_DIR=$(getBundlePath "${PLATFORM}" "${CHANNEL}") - - CSV_FILE="${OPM_BUNDLE_DIR}/manifests/che-operator.clusterserviceversion.yaml" - CSV_NAME=$(yq -r ".metadata.name" "${CSV_FILE}") - - installOPM -} - -buildOLMImages() { - # Manage catalog source for every platform in part. - # 1. Kubernetes: - # a) Use Minikube cluster. Enable registry addon, build catalog source and olm bundle images, push them to embedded private registry. - # b) Provide image registry env variables to push images to the real public registry(docker.io, quay.io etc). - # 2. Openshift: build bundle image and push it using image stream. Launch deployment with custom grpc based catalog source image to install the latest bundle. - if [[ "${PLATFORM}" == "kubernetes" ]] - then - echo "[INFO]: Kubernetes platform detected" - - # Build operator image - if [ -n "${OPERATOR_IMAGE}" ];then - echo "[INFO]: Build operator image ${OPERATOR_IMAGE}..." - pushd "${OPERATOR_REPO}" || true - docker build --no-cache -t "${OPERATOR_IMAGE}" -f Dockerfile . - docker push "${OPERATOR_IMAGE}" - echo "${OPERATOR_IMAGE}" - popd || true - - # Use operator image in the latest CSV - sed -i "s|image: quay.io/eclipse/che-operator:next|image: ${OPERATOR_IMAGE}|" "${CSV_FILE}" - sed -i 's|imagePullPolicy: Always|imagePullPolicy: IfNotPresent|' "${CSV_FILE}" - fi - - CATALOG_BUNDLE_IMAGE="${IMAGE_REGISTRY_HOST}/${IMAGE_REGISTRY_USER_NAME}/che_operator_bundle:0.0.1" - CATALOG_SOURCE_IMAGE="${IMAGE_REGISTRY_HOST}/${IMAGE_REGISTRY_USER_NAME}/testing_catalog:0.0.1" - - echo "[INFO] Build bundle image... ${CATALOG_BUNDLE_IMAGE}" - buildBundleImage "${PLATFORM}" "${CATALOG_BUNDLE_IMAGE}" "${CHANNEL}" "docker" - - echo "[INFO] Build catalog image... ${CATALOG_BUNDLE_IMAGE}" - buildCatalogImage "${CATALOG_SOURCE_IMAGE}" "${CATALOG_BUNDLE_IMAGE}" "docker" "false" - - echo "[INFO]: Successfully created catalog source container image and enabled minikube ingress." - elif [[ "${PLATFORM}" == "openshift" ]] - then - echo "[INFO]: Starting to build catalog image and push to ImageStream." - - if [ -n "${OPERATOR_IMAGE}" ]; then - # Use custom operator image, if set, in the latest CSV - sed -i "s|image: quay.io/eclipse/che-operator:next|image: ${OPERATOR_IMAGE}|" "${CSV_FILE}" - echo "[INFO]: Using custom operator image: ${OPERATOR_IMAGE}" - fi - - echo "============" - echo "[INFO] Current user is $(oc whoami)" - echo "============" - - oc new-project "${NAMESPACE}" || true - - pull_user="puller" - pull_password="puller" - add_user "${pull_user}" "${pull_password}" - - if [ -z "${KUBECONFIG}" ]; then - KUBECONFIG="${HOME}/.kube/config" - fi - TEMP_KUBE_CONFIG="/tmp/$pull_user.kubeconfig" - rm -rf "${TEMP_KUBE_CONFIG}" - cp "${KUBECONFIG}" "${TEMP_KUBE_CONFIG}" - sleep 180 - - loginLogFile="/tmp/login-log" - touch "${loginLogFile}" - loginCMD="oc login --kubeconfig=${TEMP_KUBE_CONFIG} --username=${pull_user} --password=${pull_password} > ${loginLogFile}" - timeout 900 bash -c "${loginCMD}" || echo "[ERROR] Login Fail" - echo "[INFO] $(cat "${loginLogFile}" || true)" - - echo "[INFO] Applying policy registry-viewer to user '${pull_user}'..." - oc -n "$NAMESPACE" policy add-role-to-user registry-viewer "$pull_user" - - echo "[INFO] Trying to retrieve user '${pull_user}' token..." - token=$(oc --kubeconfig=${TEMP_KUBE_CONFIG} whoami -t) - echo "[INFO] User '${pull_user}' token is: ${token}" - - oc -n "${NAMESPACE}" new-build --binary --strategy=docker --name serverless-bundle - - cp -rf "${OPM_BUNDLE_DIR}/bundle.Dockerfile" "${OPM_BUNDLE_DIR}/Dockerfile" - if oc -n "${NAMESPACE}" start-build serverless-bundle --from-dir "${OPM_BUNDLE_DIR}"; then - rm -rf "${OPM_BUNDLE_DIR}/Dockerfile" - else - rm -rf "${OPM_BUNDLE_DIR}/Dockerfile" - echo "[ERROR ]Failed to build bundle image." - exit 1 - fi - -cat </dev/null || mktemp -q -d)" - HT_PASSWD_FILE="${PASSWD_TEMP_DIR}/users.htpasswd" - touch "${HT_PASSWD_FILE}" - - htpasswd -b "${HT_PASSWD_FILE}" "$name" "$pass" - echo "====== HTPASSWD content is:========" - cat "${HT_PASSWD_FILE}" - echo "===================================" - - if ! kubectl get secret htpass-secret -n openshift-config 2>/dev/null; then - kubectl create secret generic htpass-secret \ - --from-file=htpasswd="${HT_PASSWD_FILE}" \ - -n openshift-config - fi - -cat < [] []" - exit 1 -fi - -channel=$2 -if [ "${channel}" == "" ]; then - channel="next" -fi +export OPERATOR_REPO="${GITHUB_WORKSPACE}" -namespace=$3 -if [ "${namespace}" == "" ]; then - namespace="eclipse-che-preview-test" +if [ -z "${OPERATOR_REPO}" ]; then + SCRIPT=$(readlink -f "${BASH_SOURCE[0]}") + OPERATOR_REPO=$(dirname "$(dirname "$SCRIPT")") fi +source "${OPERATOR_REPO}"/olm/olm.sh init() { - IMAGE_REGISTRY_HOST=${IMAGE_REGISTRY_HOST:-quay.io} - IMAGE_REGISTRY_USER_NAME=${IMAGE_REGISTRY_USER_NAME:-eclipse} - export CATALOG_IMAGENAME="${IMAGE_REGISTRY_HOST}/${IMAGE_REGISTRY_USER_NAME}/eclipse-che-${platform}-opm-catalog:preview" - - source "${OPERATOR_REPO}/olm/olm.sh" + unset CHANNEL + unset PLATFORM + unset CATALOG_IMAGE + unset OPERATOR_IMAGE + unset NAMESPACE + + while [[ "$#" -gt 0 ]]; do + case $1 in + '--channel'|'-c') CHANNEL="$2"; shift 1;; + '--platform'|'-p') PLATFORM="$2"; shift 1;; + '--namespace'|'-n') NAMESPACE="$2"; shift 1;; + '--catalog-image'|'-i') CATALOG_IMAGE="$2"; shift 1;; + '--help'|'-h') usage; exit;; + esac + shift 1 + done + + if [[ ! ${CHANNEL} ]] || [[ ! ${PLATFORM} ]] || [[ ! ${CATALOG_IMAGE} ]] || [[ ! ${NAMESPACE} ]]; then usage; exit 1; fi +} - OPM_BUNDLE_DIR=$(getBundlePath "${platform}" "${channel}") - CSV_FILE_PATH="${OPM_BUNDLE_DIR}/manifests/che-operator.clusterserviceversion.yaml" +usage () { + echo "Usage: $0 -p (openshift|kubernetes) -c (next|next-all-namespaces|stable) -i CATALOG_IMAGE -n NAMESPACE" + echo "Example: $0 -p openshift -c next -i quay.io/eclipse/eclipse-che-openshift-opm-catalog:test -n eclipse-che" } run() { - createNamespace "${namespace}" - + createNamespace "${NAMESPACE}" installOperatorMarketPlace - installCatalogSource "${platform}" "${namespace}" "${CATALOG_IMAGENAME}" + installCatalogSource "${PLATFORM}" "${NAMESPACE}" "${CATALOG_IMAGE}" - getBundleListFromCatalogSource "${platform}" "${namespace}" - getPreviousCSVInfo "${channel}" - getLatestCSVInfo "${channel}" + getBundleListFromCatalogSource "${PLATFORM}" "${NAMESPACE}" + getPreviousCSVInfo "${CHANNEL}" + getLatestCSVInfo "${CHANNEL}" echo "[INFO] Test update from version: ${PREVIOUS_CSV_BUNDLE_IMAGE} to: ${LATEST_CSV_BUNDLE_IMAGE}" @@ -64,19 +61,19 @@ run() { exit 1 fi - forcePullingOlmImages "${namespace}" "${PREVIOUS_CSV_BUNDLE_IMAGE}" - forcePullingOlmImages "${namespace}" "${LATEST_CSV_BUNDLE_IMAGE}" + forcePullingOlmImages "${NAMESPACE}" "${PREVIOUS_CSV_BUNDLE_IMAGE}" + forcePullingOlmImages "${NAMESPACE}" "${LATEST_CSV_BUNDLE_IMAGE}" + + subscribeToInstallation "${PLATFORM}" "${NAMESPACE}" "${CHANNEL}" "${PREVIOUS_CSV_NAME}" + installPackage "${PLATFORM}" "${NAMESPACE}" + echo "[INFO] Installation of the previous che-operator version: ${PREVIOUS_CSV_NAME} successfully completed" - subscribeToInstallation "${platform}" "${namespace}" "${channel}" "${PREVIOUS_CSV_NAME}" - installPackage "${platform}" "${namespace}" - echo -e "\u001b[32m Installation of the previous che-operator version: ${PREVIOUS_CSV_NAME} successfully completed \u001b[0m" - applyCRCheCluster "${platform}" "${namespace}" "${CSV_FILE_PATH}" - waitCheServerDeploy "${namespace}" + applyCheClusterCR ${PREVIOUS_CSV_NAME} ${PLATFORM} + waitCheServerDeploy "${NAMESPACE}" - installPackage "${platform}" "${namespace}" - echo -e "\u001b[32m Installation of the latest che-operator version: ${LATEST_CSV_NAME} successfully completed \u001b[0m" + installPackage "${PLATFORM}" "${NAMESPACE}" + echo "[INFO] Installation of the latest che-operator version: ${LATEST_CSV_NAME} successfully completed" } -init +init "$@" run -echo -e "\u001b[32m Done. \u001b[0m"