Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Anatolii Bazko <[email protected]>
  • Loading branch information
tolusha committed Jun 11, 2021
1 parent ae7d93b commit 0464954
Show file tree
Hide file tree
Showing 15 changed files with 121 additions and 3,943 deletions.
49 changes: 19 additions & 30 deletions .github/bin/check-resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,27 @@ fi
installOperatorSDK() {
OPERATOR_SDK_BINARY=$(command -v operator-sdk) || true
if [[ ! -x "${OPERATOR_SDK_BINARY}" ]]; then
OPERATOR_SDK_TEMP_DIR="$(mktemp -q -d -t "OPERATOR_SDK_XXXXXX" 2>/dev/null || mktemp -q -d)"
pushd "${OPERATOR_SDK_TEMP_DIR}" || exit

echo "[INFO] Downloading 'operator-sdk' cli tool..."

OPERATOR_SDK_TEMP_DIR="$(mktemp -q -d -t "OPERATOR_SDK_XXXXXX" 2>/dev/null || mktemp -q -d)"
OPERATOR_SDK=$(yq -r ".\"operator-sdk\"" "${ROOT_PROJECT_DIR}/REQUIREMENTS")
curl -sLo operator-sdk $(curl -sL https://api.github.com/repos/operator-framework/operator-sdk/releases/tags/${OPERATOR_SDK} | jq -r "[.assets[] | select(.name == \"operator-sdk-${OPERATOR_SDK}-x86_64-linux-gnu\")] | first | .browser_download_url")
export OPERATOR_SDK_BINARY="${OPERATOR_SDK_TEMP_DIR}/operator-sdk"
chmod +x "${OPERATOR_SDK_BINARY}"

echo "[INFO] Downloading completed!"
echo "[INFO] $(${OPERATOR_SDK_BINARY} version)"

popd || exit
fi
}

updateResources() {
export NO_DATE_UPDATE="true"
export NO_INCREMENT="true"

pushd "${ROOT_PROJECT_DIR}" || true
source "${ROOT_PROJECT_DIR}/olm/update-resources.sh"
popd || true
. "${ROOT_PROJECT_DIR}/olm/update-resources.sh"
}

# check_che_types function check first if pkg/apis/org/v1/che_types.go file suffer modifications and
Expand All @@ -56,9 +57,6 @@ checkCRDs() {
local CRD_V1="deploy/crds/org_v1_che_crd.yaml"
local CRD_V1BETA1="deploy/crds/org_v1_che_crd-v1beta1.yaml"

pushd "${ROOT_PROJECT_DIR}"
source "${ROOT_PROJECT_DIR}/olm/update-resources.sh"

changedFiles=($(git diff --name-only))

# Check if there are any difference in the crds. If yes, then fail check.
Expand All @@ -69,7 +67,6 @@ checkCRDs() {
else
echo "[INFO] CRDs files are up to date."
fi
popd
}

checkNightlyOlmBundle() {
Expand All @@ -79,8 +76,6 @@ checkNightlyOlmBundle() {
local CRD_FILE_KUBERNETES="deploy/olm-catalog/nightly/eclipse-che-preview-kubernetes/manifests/org_v1_che_crd.yaml"
local CRD_FILE_OPENSHIFT="deploy/olm-catalog/nightly/eclipse-che-preview-openshift/manifests/org_v1_che_crd.yaml"

pushd "${ROOT_PROJECT_DIR}" || true

changedFiles=($(git diff --name-only))
if [[ " ${changedFiles[*]} " =~ $CSV_FILE_OPENSHIFT ]] || [[ " ${changedFiles[*]} " =~ $CSV_FILE_OPENSHIFT ]] || \
[[ " ${changedFiles[*]} " =~ $CRD_FILE_KUBERNETES ]] || [[ " ${changedFiles[*]} " =~ $CRD_FILE_OPENSHIFT ]]; then
Expand All @@ -90,16 +85,12 @@ checkNightlyOlmBundle() {
else
echo "[INFO] Nightly bundles are up to date."
fi

popd || true
}

checkDockerfile() {
# files to check
local Dockerfile="Dockerfile"

pushd "${ROOT_PROJECT_DIR}" || true

changedFiles=($(git diff --name-only))
if [[ " ${changedFiles[*]} " =~ $Dockerfile ]]; then
echo "[ERROR] Dockerfile is not up to date"
Expand All @@ -108,16 +99,12 @@ checkDockerfile() {
else
echo "[INFO] Dockerfile is up to date."
fi

popd || true
}

checkOperatorYaml() {
# files to check
local OperatorYaml="deploy/operator.yaml"

pushd "${ROOT_PROJECT_DIR}" || true

changedFiles=($(git diff --name-only))
if [[ " ${changedFiles[*]} " =~ $OperatorYaml ]]; then
echo "[ERROR] $OperatorYaml is not up to date"
Expand All @@ -126,21 +113,18 @@ checkOperatorYaml() {
else
echo "[INFO] $OperatorYaml is up to date."
fi

popd || true
}

checkDWCO() {
checkDW() {
# files to check
local DWCO_CRD="deploy/dwco/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml"
local CWCO_CONFIGMAP="deploy/dwco/devworkspace-che-configmap.ConfigMap.yaml"
local DWCO_SERVICE="deploy/dwco/devworkspace-che-controller-manager-metrics-service.Service.yaml"

pushd "${ROOT_PROJECT_DIR}" || true
local CHEMANAGER_CRD="deploy/dev-workspace/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml"
local DWROUTINGS_CRD="deploy/dev-workspace/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml"
local CWCO_CONFIGMAP="deploy/dev-workspace/devworkspace-che-configmap.ConfigMap.yaml"
local DWCO_SERVICE="deploy/dev-workspace/devworkspace-che-controller-manager-metrics-service.Service.yaml"

changedFiles=($(git diff --name-only))
if [[ " ${changedFiles[*]} " =~ $DWCO_CRD ]] || [[ " ${changedFiles[*]} " =~ $CWCO_CONFIGMAP ]] || \
[[ " ${changedFiles[*]} " =~ $DWCO_SERVICE ]]; then
if [[ " ${changedFiles[*]} " =~ $CHEMANAGER_CRD ]] || [[ " ${changedFiles[*]} " =~ $CWCO_CONFIGMAP ]] || \
[[ " ${changedFiles[*]} " =~ $DWCO_SERVICE ]] || [[ " ${changedFiles[*]} " =~ $DWROUTINGS_CRD ]]; then
echo "[ERROR] DWCO resources are not up to date: ${BASH_REMATCH}"
echo "[ERROR] Run 'olm/update-resources.sh' to download them."
exit 1
Expand All @@ -150,11 +134,16 @@ checkDWCO() {
}

installOperatorSDK

pushd "${ROOT_PROJECT_DIR}" || true

updateResources
checkCRDs
checkNightlyOlmBundle
checkDockerfile
checkOperatorYaml
checkDWCO
checkDW

popd || true

echo "[INFO] Done."
31 changes: 22 additions & 9 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,26 @@
# Red Hat, Inc. - initial API and implementation

set -e
set -x

BASE_DIR=$(cd "$(dirname "$0")"; pwd)

NAMESPACE="eclipse-che"
CHE_OPERATOR_IMAGE="quay.io/eclipse/che-operator:nightly"
LOGS=false

while [[ "$#" -gt 0 ]]; do
case $1 in
'--namespace'|'-n') NAMESPACE=$2; shift 1;;
'--che-operator-image') CHE_OPERATOR_IMAGE=$2; shift 1;;
'--logs') LOGS=true;
esac
shift 1
done

echo "[INFO] Deploying Eclipse Che in namespace: "$NAMESPACE
set +e; oc create namespace $ECLIPSE_CHE_NAMESPACE; set -e

echo "[INFO] Creating SA roles and clusterroles"

oc apply -f ${BASE_DIR}/deploy/service_account.yaml -n $NAMESPACE
oc apply -f ${BASE_DIR}/deploy/role.yaml -n $NAMESPACE
oc apply -f ${BASE_DIR}/deploy/role_binding.yaml -n $NAMESPACE
Expand All @@ -34,17 +39,25 @@ oc apply -f ${BASE_DIR}/deploy/cluster_role_binding.yaml -n $NAMESPACE
oc apply -f ${BASE_DIR}/deploy/proxy_cluster_role.yaml -n $NAMESPACE
oc apply -f ${BASE_DIR}/deploy/proxy_cluster_role_binding.yaml -n $NAMESPACE

oc apply -f ${BASE_DIR}/deploy/crds/org_v1_che_crd.yaml -n $NAMESPACE
oc apply -f ${BASE_DIR}/deploy/dwco/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml -n $NAMESPACE
oc apply -f ${BASE_DIR}/deploy/dwco/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml -n $NAMESPACE
echo "[INFO] Creating Custom Resource Difinition"

# sometimes the operator cannot get CRD right away
oc apply -f ${BASE_DIR}/deploy/crds/org_v1_che_crd.yaml -n $NAMESPACE
oc apply -f ${BASE_DIR}/deploy/dev-workspace/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml -n $NAMESPACE
oc apply -f ${BASE_DIR}/deploy/dev-workspace/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml -n $NAMESPACE
sleep 5

# patch and apply operator.yaml
cp ${BASE_DIR}/deploy/operator.yaml /tmp/operator.yaml
echo "[INFO] Creating operator deployment, image: "$CHE_OPERATOR_IMAGE

cp -f ${BASE_DIR}/deploy/operator.yaml /tmp/operator.yaml
yq -riyY "( .spec.template.spec.containers[] | select(.name == \"che-operator\") | .image ) = \"${CHE_OPERATOR_IMAGE}\"" /tmp/operator.yaml

oc apply -f /tmp/operator.yaml -n $NAMESPACE

# create CR
echo "[INFO] Creating Custom Resource"

oc apply -f ${BASE_DIR}/deploy/crds/org_v1_che_cr.yaml -n $NAMESPACE

if [[ $LOGS == true ]]; then
echo "[INFO] Start printing logs"
oc logs $(oc get pods -o json -n $NAMESPACE | jq -r '.items[] | select(.metadata.name | test("che-operator-")).metadata.name') -n $NAMESPACE --all-containers
fi
132 changes: 0 additions & 132 deletions deploy/dwco/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml

This file was deleted.

8 changes: 0 additions & 8 deletions deploy/dwco/devworkspace-che-configmap.ConfigMap.yaml

This file was deleted.

This file was deleted.

Loading

0 comments on commit 0464954

Please sign in to comment.