Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
  • Loading branch information
tolusha committed Dec 23, 2021
1 parent 2f48bf5 commit 082b29a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 27 deletions.
7 changes: 4 additions & 3 deletions .ci/oci-single-host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 10 additions & 18 deletions .github/bin/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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 \
Expand Down
4 changes: 2 additions & 2 deletions olm/buildCatalog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 2 additions & 4 deletions olm/olm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}"
Expand Down

0 comments on commit 082b29a

Please sign in to comment.