Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: CheCluster API v2 #1324

Merged
merged 15 commits into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/cico_updates_openshift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ set -e
set -x

export OPERATOR_REPO=$(dirname $(dirname $(readlink -f "$0")));
source "${OPERATOR_REPO}"/.github/bin/common.sh
source "${OPERATOR_REPO}/.github/bin/common.sh"

#Stop execution on any error
trap "catchFinish" EXIT SIGINT
Expand Down
4 changes: 2 additions & 2 deletions .ci/oci-devworkspace-happy-path.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ set -x
export CHE_REPO_BRANCH="main"

export OPERATOR_REPO=$(dirname $(dirname $(readlink -f "$0")));
source "${OPERATOR_REPO}"/.github/bin/common.sh
source "${OPERATOR_REPO}/.github/bin/common.sh"
source <(curl -s https://raw.githubusercontent.com/eclipse/che/${CHE_REPO_BRANCH}/tests/devworkspace-happy-path/common.sh)

#Stop execution on any error
Expand All @@ -29,7 +29,7 @@ overrideDefaults() {
}

deployChe() {
deployEclipseCheOnWithOperator "chectl" "openshift" ${CURRENT_OPERATOR_VERSION_TEMPLATE_PATH} "true"
deployEclipseCheWithOperator "chectl" "openshift" ${CURRENT_OPERATOR_VERSION_TEMPLATE_PATH} "true"
}

initDefaults
Expand Down
2 changes: 1 addition & 1 deletion .ci/oci-disconnected.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set -o pipefail
set -u

export OPERATOR_REPO=$(dirname $(dirname $(readlink -f "$0")));
source "${OPERATOR_REPO}"/.github/bin/common.sh
source "${OPERATOR_REPO}/.github/bin/common.sh"

# Define Disconnected tests environment
export INTERNAL_REGISTRY_URL=${INTERNAL_REGISTRY_URL-"UNDEFINED"}
Expand Down
5 changes: 2 additions & 3 deletions .ci/oci-nightly-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ set -e
set -x

export OPERATOR_REPO=$(dirname $(dirname $(readlink -f "$0")));
source "${OPERATOR_REPO}"/olm/olm.sh
source "${OPERATOR_REPO}"/.github/bin/common.sh
source "${OPERATOR_REPO}/.github/bin/common.sh"

#Stop execution on any error
trap "catchFinish" EXIT SIGINT
Expand All @@ -33,7 +32,7 @@ overrideDefaults() {

runTests() {
deployDevWorkspaceOperator "stable"
deployEclipseCheOnWithOperator "chectl" "openshift" ${LAST_OPERATOR_VERSION_TEMPLATE_PATH} "false"
deployEclipseCheWithOperator "chectl" "openshift" ${LAST_OPERATOR_VERSION_TEMPLATE_PATH} "false"
updateEclipseChe "chectl" "openshift" ${CURRENT_OPERATOR_VERSION_TEMPLATE_PATH} "true"
}

Expand Down
4 changes: 2 additions & 2 deletions .ci/oci-proxy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set -o pipefail
set -u

export OPERATOR_REPO=$(dirname $(dirname $(readlink -f "$0")));
source "${OPERATOR_REPO}"/.github/bin/common.sh
source "${OPERATOR_REPO}/.github/bin/common.sh"

#Stop execution on any error
trap "catchFinish" EXIT SIGINT
Expand All @@ -29,7 +29,7 @@ overrideDefaults() {
}

runTests() {
deployEclipseCheOnWithOperator "chectl" "openshift" ${CURRENT_OPERATOR_VERSION_TEMPLATE_PATH} "true"
deployEclipseCheWithOperator "chectl" "openshift" ${CURRENT_OPERATOR_VERSION_TEMPLATE_PATH} "true"
}

initDefaults
Expand Down
10 changes: 5 additions & 5 deletions .ci/oci-single-host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ set -e
set -x

export OPERATOR_REPO=$(dirname $(dirname $(readlink -f "$0")));
source "${OPERATOR_REPO}"/.github/bin/common.sh
source "${OPERATOR_REPO}/.github/bin/common.sh"

#Stop execution on any error
trap "catchFinish" EXIT SIGINT
Expand All @@ -31,12 +31,12 @@ overrideDefaults() {
}

runTests() {
createNamespace ${NAMESPACE}
createNamespace "${NAMESPACE}"

useCustomOperatorImageInCSV ${OPERATOR_IMAGE}
useCustomOperatorImageInCSV "${OPERATOR_IMAGE}"

echo "$(getCheClusterCRFromExistedCSV)" | oc apply -n "${NAMESPACE}" -f -
waitEclipseCheDeployed $(getCheVersionFromExistedCSV)
getCheClusterCRFromExistedCSV | oc apply -n "${NAMESPACE}" -f -
waitEclipseCheDeployed "$(getCheVersionFromExistedCSV)"

waitDevWorkspaceControllerStarted
}
Expand Down
2 changes: 1 addition & 1 deletion .github/bin/check-bundle-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ compareVersions() {

if (( $VERSION_NEW_NUMBER <= $VERSION_CURRENT_NUMBER )); then
echo "[ERROR] New next bundle version is less than the current one."
echo "[ERROR] Please update next bundle with script 'make update-resources -s'"
echo "[ERROR] Please update next bundle with script 'make update-dev-resources'"
exit 1
fi
}
Expand Down
148 changes: 13 additions & 135 deletions .github/bin/check-resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,151 +11,29 @@
# Red Hat, Inc. - initial API and implementation
#

# Checks if repository resources are up to date:
# - CRDs
# - next olm bundle
# - Dockerfile & operator.yaml
# - DW resources
# - Helm charts

set -e

ROOT_PROJECT_DIR="${GITHUB_WORKSPACE}"
if [ -z "${ROOT_PROJECT_DIR}" ]; then
SCRIPT=$(readlink -f "${BASH_SOURCE[0]}")
ROOT_PROJECT_DIR=$(dirname $(dirname $(dirname ${SCRIPT})))
ROOT_PROJECT_DIR=$(dirname $(dirname $(dirname "${SCRIPT}")))
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 "${ROOT_PROJECT_DIR}" || exit
make download-operator-sdk OP_SDK_DIR="${OPERATOR_SDK_TEMP_DIR}"
export OPERATOR_SDK_BINARY="${OPERATOR_SDK_TEMP_DIR}/operator-sdk"
popd || exit
fi
}

updateResources() {
echo "[INFO] Update resources with skipping version incrementation and timestamp..."

pushd "${ROOT_PROJECT_DIR}" || exit
make update-resources NO_DATE_UPDATE="true" NO_INCREMENT="true" -s
popd || exit
}

# check_che_types function check first if api/v1/checluster_types.go file suffer modifications and
# in case of modification should exist also modifications in config/crd/bases/* folder.
checkCRDs() {
echo "[INFO] Checking CRDs"

# files to check
local checluster_CRD_V1="config/crd/bases/org_v1_che_crd.yaml"
local chebackupserverconfiguration_CRD_V1="config/crd/bases/org.eclipse.che_chebackupserverconfigurations_crd.yaml"
local checlusterbackup_CRD_V1="config/crd/bases/org.eclipse.che_checlusterbackups_crd.yaml"
local checlusterrestore_CRD_V1="config/crd/bases/org.eclipse.che_checlusterrestores_crd.yaml"

changedFiles=($(cd ${ROOT_PROJECT_DIR}; git diff --name-only))
# Check if there are any difference in the crds. If yes, then fail check.
if [[ " ${changedFiles[*]} " =~ $checluster_CRD_V1 ]] || \
[[ " ${changedFiles[*]} " =~ $chebackupserverconfiguration_CRD_V1 ]] || \
[[ " ${changedFiles[*]} " =~ $checlusterbackup_CRD_V1 ]] || \
[[ " ${changedFiles[*]} " =~ $checlusterrestore_CRD_V1 ]]
then
echo "[ERROR] CRD file is not up to date: ${BASH_REMATCH}"
echo "[ERROR] Run 'make update-resources -s' to regenerate CRD files."
exit 1
else
echo "[INFO] CRDs files are up to date."
fi
}

checkNextOlmBundle() {
# files to check
local CSV_OPENSHIFT="bundle/next/eclipse-che-preview-openshift/manifests"

changedFiles=($(cd ${ROOT_PROJECT_DIR}; git diff --name-only))
if [[ " ${changedFiles[*]} " =~ $CSV_OPENSHIFT ]]; then
echo "[ERROR] Nighlty bundle is not up to date: ${BASH_REMATCH}"
echo "[ERROR] Run 'make update-resources -s' to regenerate next bundle files."
exit 1
else
echo "[INFO] Next bundles are up to date."
fi
}

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

changedFiles=($(cd ${ROOT_PROJECT_DIR}; git diff --name-only))
if [[ " ${changedFiles[*]} " =~ $Dockerfile ]]; then
echo "[ERROR] Dockerfile is not up to date"
echo "[ERROR] Run 'make update-resources -s' to update Dockerfile"
exit 1
else
echo "[INFO] Dockerfile is up to date."
fi
}

checkOperatorYaml() {
# files to check
local managerYaml="config/manager/manager.yaml"

changedFiles=($(cd ${ROOT_PROJECT_DIR}; git diff --name-only))
if [[ " ${changedFiles[*]} " =~ $managerYaml ]]; then
echo "[ERROR] $managerYaml is not up to date"
echo "[ERROR] Run 'make update-resources -s' to update $managerYaml"
exit 1
else
echo "[INFO] $managerYaml is up to date."
fi
}

checkRoles() {
# files to check
local RoleYaml="config/rbac/role.yaml"
local ClusterRoleYaml="config/rbac/cluster_role.yaml"

changedFiles=(
$(git diff --name-only)
)
if [[ " ${changedFiles[*]} " =~ $RoleYaml ]] || [[ " ${changedFiles[*]} " =~ $ClusterRoleYaml ]]; then
echo "[ERROR] Roles are not up to date: ${BASH_REMATCH}"
echo "[ERROR] Run 'make update-resources -s' to update them."
exit 1
else
echo "[INFO] Roles are up to date."
fi
}

checkHelmCharts() {
changedFiles=(
$(git diff --name-only)
)
if [[ " ${changedFiles[*]} " =~ helmcharts ]]; then
echo "[ERROR] Helm Charts are not up to date"
echo "[ERROR] Run 'make update-resources -s' to update them."
exit 1
else
echo "[INFO] Helm Charts are up to date."
fi
}
pushd "${ROOT_PROJECT_DIR}" || true

installOperatorSDK
# Update resources
make update-dev-resources INCREMENT_BUNDLE_VERSION=false

pushd "${ROOT_PROJECT_DIR}" || true
if [[ $(git diff --name-only | wc -l) != 0 ]]; then
# Print difference
git --no-pager diff

updateResources
checkCRDs
checkRoles
checkNextOlmBundle
checkDockerfile
checkOperatorYaml
checkHelmCharts
echo "[ERROR] Resources are not up to date."
echo "[ERROR] Run 'make update-dev-resources' to update them."
exit 1
else
echo "[INFO] Done."
fi

popd || true

echo "[INFO] Done."
Loading