Skip to content

Commit

Permalink
Merge branch 'main' into allow_roles_update
Browse files Browse the repository at this point in the history
  • Loading branch information
mshaposhnik committed Jul 21, 2021
2 parents abec898 + 6bf5c65 commit 28d47d9
Show file tree
Hide file tree
Showing 2,430 changed files with 336,679 additions and 195,963 deletions.
2 changes: 1 addition & 1 deletion .ci/oci-disconnected.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ podman push --authfile="${REG_CREDS}" --tls-verify=false "${INTERNAL_REGISTRY_UR
podman push --authfile="${REG_CREDS}" --tls-verify=false "${INTERNAL_REGISTRY_URL}"/"${ORGANIZATION}"/che-plugin-registry:"${TAG}"

# Get all containers images used in eclipse-che deployment(postgresql, che-server, che-dashboard, keycloak...)
curl -sSLo- https://raw.githubusercontent.com/eclipse-che/che-operator/main/deploy/operator.yaml > /tmp/yam.yaml
curl -sSLo- https://raw.githubusercontent.com/eclipse-che/che-operator/main/config/manager/manager.yaml > /tmp/yam.yaml
export ARRAY_OF_IMAGES=$(cat /tmp/yam.yaml | yq '.spec.template.spec.containers[0].env[] | select(.name|test("RELATED_")) | .value' -r)

# Remove from Array of images devfile and plugins because will be builded using build.sh in offline mode.
Expand Down
6 changes: 3 additions & 3 deletions .github/bin/check-bundle-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ if [ -z "${ROOT_PROJECT_DIR}" ]; then
ROOT_PROJECT_DIR=$(dirname "$(dirname "${BASE_DIR}")")
fi

CSV_KUBERNETES_NEW="deploy/olm-catalog/nightly/eclipse-che-preview-kubernetes/manifests/che-operator.clusterserviceversion.yaml"
CSV_KUBERNETES_NEW="bundle/nightly/eclipse-che-preview-kubernetes/manifests/che-operator.clusterserviceversion.yaml"
CSV_KUBERNETES_CURRENT=https://raw.githubusercontent.com/eclipse-che/che-operator/main/deploy/olm-catalog/nightly/eclipse-che-preview-kubernetes/manifests/che-operator.clusterserviceversion.yaml

CSV_OPENSHIFT_NEW="deploy/olm-catalog/nightly/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml"
CSV_OPENSHIFT_NEW="bundle/nightly/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml"
CSV_OPENSHIFT_CURRENT=https://raw.githubusercontent.com/eclipse-che/che-operator/main/deploy/olm-catalog/nightly/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml

checkNightlyBundleVersions() {
Expand Down Expand Up @@ -56,7 +56,7 @@ compareVersions() {

if (( $VERSION_NEW_NUMBER <= $VERSION_CURRENT_NUMBER )); then
echo "[ERROR] New nightly bundle version is less than the current one."
echo "[ERROR] Please update nightly bundle with script 'olm/update-resources.sh'"
echo "[ERROR] Please update nightly bundle with script 'make update-resources -s'"
exit 1
fi
}
Expand Down
75 changes: 30 additions & 45 deletions .github/bin/check-resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,56 +28,47 @@ 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=$(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")
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"
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"
. "${ROOT_PROJECT_DIR}/olm/update-resources.sh"
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 pkg/apis/org/v1/che_types.go file suffer modifications and
# in case of modification should exist also modifications in deploy/crds/* folder.
# 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="deploy/crds/org_v1_che_crd.yaml"
local chebackupserverconfiguration_CRD_V1="deploy/crds/org.eclipse.che_chebackupserverconfigurations_crd.yaml"
local checlusterbackup_CRD_V1="deploy/crds/org.eclipse.che_checlusterbackups_crd.yaml"
local checlusterrestore_CRD_V1="org.eclipse.che_checlusterrestores_crd.yaml"
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"

local checluster_CRD_V1BETA1="deploy/crds/org_v1_che_crd-v1beta1.yaml"
local chebackupserverconfiguration_CRD_V1BETA1="deploy/crds/org.eclipse.che_chebackupserverconfigurations_crd-v1beta1.yaml"
local checlusterbackup_CRD_V1BETA1="deploy/crds/org.eclipse.che_checlusterbackups_crd-v1beta1.yaml"
local checlusterrestore_CRD_V1BETA1="deploy/crds/org.eclipse.che_checlusterrestores_crd-v1beta1.yaml"

changedFiles=(
$(git diff --name-only)
)
local checluster_CRD_V1BETA1="config/crd/bases/org_v1_che_crd-v1beta1.yaml"
local chebackupserverconfiguration_CRD_V1BETA1="config/crd/bases/org.eclipse.che_chebackupserverconfigurations_crd-v1beta1.yaml"
local checlusterbackup_CRD_V1BETA1="config/crd/bases/org.eclipse.che_checlusterbackups_crd-v1beta1.yaml"
local checlusterrestore_CRD_V1BETA1="config/crd/bases/org.eclipse.che_checlusterrestores_crd-v1beta1.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[*]} " =~ $checluster_CRD_V1BETA1 ]] || \
[[ " ${changedFiles[*]} " =~ $chebackupserverconfiguration_CRD_V1 ]] || [[ " ${changedFiles[*]} " =~ $chebackupserverconfiguration_CRD_V1BETA1 ]] || \
[[ " ${changedFiles[*]} " =~ $checlusterbackup_CRD_V1 ]] || [[ " ${changedFiles[*]} " =~ $checlusterbackup_CRD_V1BETA1 ]] || \
[[ " ${changedFiles[*]} " =~ $checlusterrestore_CRD_V1 ]] || [[ " ${changedFiles[*]} " =~ $checlusterrestore_CRD_V1BETA1 ]]
then
echo "[ERROR] CRD file is not up to date: ${BASH_REMATCH}"
echo "[ERROR] Run 'olm/update-resources.sh' to regenerate CRD files."
echo "[ERROR] Run 'make update-resources -s' to regenerate CRD files."
exit 1
else
echo "[INFO] CRDs files are up to date."
Expand All @@ -86,18 +77,16 @@ checkCRDs() {

checkNightlyOlmBundle() {
# files to check
local CSV_FILE_KUBERNETES="deploy/olm-catalog/nightly/eclipse-che-preview-kubernetes/manifests/che-operator.clusterserviceversion.yaml"
local CSV_FILE_OPENSHIFT="deploy/olm-catalog/nightly/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml"
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"
local CSV_FILE_KUBERNETES="bundle/nightly/eclipse-che-preview-kubernetes/manifests/che-operator.clusterserviceversion.yaml"
local CSV_FILE_OPENSHIFT="bundle/nightly/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml"
local CRD_FILE_KUBERNETES="bundle/nightly/eclipse-che-preview-kubernetes/manifests/org_v1_che_crd.yaml"
local CRD_FILE_OPENSHIFT="bundle/nightly/eclipse-che-preview-openshift/manifests/org_v1_che_crd.yaml"

changedFiles=(
$(git diff --name-only)
)
changedFiles=($(cd ${ROOT_PROJECT_DIR}; git diff --name-only))
if [[ " ${changedFiles[*]} " =~ $CSV_FILE_OPENSHIFT ]] || [[ " ${changedFiles[*]} " =~ $CSV_FILE_OPENSHIFT ]] || \
[[ " ${changedFiles[*]} " =~ $CRD_FILE_KUBERNETES ]] || [[ " ${changedFiles[*]} " =~ $CRD_FILE_OPENSHIFT ]]; then
echo "[ERROR] Nighlty bundle is not up to date: ${BASH_REMATCH}"
echo "[ERROR] Run 'olm/update-resources.sh' to regenerate CSV/CRD files."
echo "[ERROR] Run 'make update-resources -s' to regenerate CSV/CRD files."
exit 1
else
echo "[INFO] Nightly bundles are up to date."
Expand All @@ -108,12 +97,10 @@ checkDockerfile() {
# files to check
local Dockerfile="Dockerfile"

changedFiles=(
$(git diff --name-only)
)
changedFiles=($(cd ${ROOT_PROJECT_DIR}; git diff --name-only))
if [[ " ${changedFiles[*]} " =~ $Dockerfile ]]; then
echo "[ERROR] Dockerfile is not up to date"
echo "[ERROR] Run 'olm/update-resources.sh' to update Dockerfile"
echo "[ERROR] Run 'make update-resources -s' to update Dockerfile"
exit 1
else
echo "[INFO] Dockerfile is up to date."
Expand All @@ -122,14 +109,12 @@ checkDockerfile() {

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

changedFiles=(
$(git diff --name-only)
)
changedFiles=($(cd ${ROOT_PROJECT_DIR}; git diff --name-only))
if [[ " ${changedFiles[*]} " =~ $OperatorYaml ]]; then
echo "[ERROR] $OperatorYaml is not up to date"
echo "[ERROR] Run 'olm/update-resources.sh' to update $OperatorYaml"
echo "[ERROR] Run 'make update-resources -s' to update $OperatorYaml"
exit 1
else
echo "[INFO] $OperatorYaml is up to date."
Expand Down
70 changes: 49 additions & 21 deletions .github/bin/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ initDefaults() {
export OPERATOR_IMAGE="test/che-operator:test"
export DEFAULT_DEVFILE="https://raw.githubusercontent.com/eclipse-che/che-devfile-registry/master/devfiles/go/devfile.yaml"
export CHE_EXPOSURE_STRATEGY="multi-host"
export OPENSHIFT_NIGHTLY_CSV_FILE="${OPERATOR_REPO}/deploy/olm-catalog/nightly/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml"
export OPENSHIFT_NIGHTLY_CSV_FILE="${OPERATOR_REPO}/bundle/nightly/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml"
export DEV_WORKSPACE_CONTROLLER_VERSION="main"
export DEV_WORKSPACE_ENABLE="false"

Expand All @@ -48,12 +48,13 @@ initDefaults() {
}

initLatestTemplates() {
rm -rf /tmp/devfile-devworkspace-operator-*
curl -L https://api.github.com/repos/devfile/devworkspace-operator/zipball/${DEV_WORKSPACE_CONTROLLER_VERSION} > /tmp/devworkspace-operator.zip && \
unzip /tmp/devworkspace-operator.zip */deploy/deployment/* -d /tmp && \
mkdir -p /tmp/devworkspace-operator/templates/ && \
mv /tmp/devfile-devworkspace-operator-*/deploy ${TEMPLATES}/devworkspace

cp -rf ${OPERATOR_REPO}/deploy/* "${TEMPLATES}/che-operator"
prepareTemplates "${OPERATOR_REPO}" "${TEMPLATES}/che-operator"
}

getLatestsStableVersions() {
Expand Down Expand Up @@ -89,14 +90,20 @@ initStableTemplates() {
mkdir -p "${LAST_OPERATOR_TEMPLATE}/che-operator"
mkdir -p "${PREVIOUS_OPERATOR_TEMPLATE}/che-operator"

cp -rf ${previousOperatorPath}/deploy/* "${PREVIOUS_OPERATOR_TEMPLATE}/che-operator"
cp -rf ${lastOperatorPath}/deploy/* "${LAST_OPERATOR_TEMPLATE}/che-operator"
# todo: set up final version before merge pr...
compareResult=$(pysemver compare "${LAST_PACKAGE_VERSION}" "7.34.0")
if [ "${compareResult}" == "1" ]; then
prepareTemplates "${lastOperatorPath}" "${LAST_OPERATOR_TEMPLATE}/che-operator"
else
cp -rf ${lastOperatorPath}/deploy/* "${LAST_OPERATOR_TEMPLATE}/che-operator"
fi
}

# Utility to wait for a workspace to be started after workspace:create.
waitWorkspaceStart() {
export x=0
while [ $x -le 180 ]
timeout=240
while [ $x -le $timeout ]
do
login

Expand All @@ -114,9 +121,9 @@ waitWorkspaceStart() {
x=$(( x+1 ))
done

if [ $x -gt 180 ]
if [ $x -gt $timeout ]
then
echo "[ERROR] Workspace didn't start after 3 minutes."
echo "[ERROR] Workspace didn't start after 4 minutes."
exit 1
fi
}
Expand Down Expand Up @@ -174,6 +181,38 @@ copyCheOperatorImageToMinishift() {
eval $(minishift docker-env) && docker load -i /tmp/operator.tar && rm /tmp/operator.tar
}

# Prepare chectl che-operator templates
prepareTemplates() {
if [ -n "${1}" ]; then
SRC_TEMPLATES="${1}"
else
echo "[ERROR] Specify templates original location"
exit 1
fi

if [ -n "${2}" ]; then
TARGET_TEMPLATES="${2}"
else
echo "[ERROR] Specify templates target location"
exit 1
fi

mkdir -p "${SRC_TEMPLATES}"

cp -f "${SRC_TEMPLATES}/config/manager/manager.yaml" "${TARGET_TEMPLATES}/operator.yaml"

cp -rf "${SRC_TEMPLATES}/config/crd/bases/" "${TARGET_TEMPLATES}/crds/"

cp -f "${SRC_TEMPLATES}/config/rbac/role.yaml" "${TARGET_TEMPLATES}/"
cp -f "${SRC_TEMPLATES}/config/rbac/role_binding.yaml" "${TARGET_TEMPLATES}/"
cp -f "${SRC_TEMPLATES}/config/rbac/cluster_role.yaml" "${TARGET_TEMPLATES}/"
cp -f "${SRC_TEMPLATES}/config/rbac/cluster_rolebinding.yaml" "${TARGET_TEMPLATES}/"
cp -f "${SRC_TEMPLATES}/config/rbac/service_account.yaml" "${TARGET_TEMPLATES}/"

cp -f "${SRC_TEMPLATES}/config/samples/org.eclipse.che_v1_checluster.yaml" "${TARGET_TEMPLATES}/crds/org_v1_che_cr.yaml"
cp -f "${SRC_TEMPLATES}/config/crd/bases/org_v1_che_crd-v1beta1.yaml" "${TARGET_TEMPLATES}/crds/org_v1_che_crd-v1beta1.yaml"
}

deployEclipseCheStable(){
local installer=$1
local platform=$2
Expand All @@ -194,7 +233,8 @@ deployEclipseCheWithTemplates() {
local templates=$4

echo "[INFO] Eclipse Che custom resource"
cat ${templates}/che-operator/crds/org_v1_che_cr.yaml
local crSample=${templates}/che-operator/crds/org_v1_che_cr.yaml
cat ${crSample}

echo "[INFO] Eclipse Che operator deployment"
cat ${templates}/che-operator/operator.yaml
Expand All @@ -206,7 +246,7 @@ deployEclipseCheWithTemplates() {
--chenamespace ${NAMESPACE} \
--che-operator-image ${image} \
--skip-kubernetes-health-check \
--che-operator-cr-yaml ${templates}/che-operator/crds/org_v1_che_cr.yaml \
--che-operator-cr-yaml ${crSample} \
--templates ${templates}
}

Expand Down Expand Up @@ -332,18 +372,6 @@ setCustomOperatorImage() {
insecurePrivateDockerRegistry() {
IMAGE_REGISTRY_HOST="127.0.0.1:5000"
export IMAGE_REGISTRY_HOST

# local dockerDaemonConfig="/etc/docker/daemon.json"
# sudo mkdir -p "/etc/docker"
# sudo touch "${dockerDaemonConfig}"

# config="{\"insecure-registries\" : [\"${IMAGE_REGISTRY_HOST}\"]}"
# echo "${config}" | sudo tee "${dockerDaemonConfig}"

# if [ -x "$(command -v docker)" ]; then
# echo "[INFO] Restart docker daemon to set up private registry info."
# sudo service docker restart
# fi
}

# Utility to print objects created by Openshift CI automatically
Expand Down
6 changes: 3 additions & 3 deletions .github/bin/minikube/test-backup-restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ waitBackupFinished() {
}

waitRestoreFinished() {
maxAttempts=75
maxAttempts=130
count=0
while [ $count -le $maxAttempts ]; do
state=$(kubectl get checlusterrestore eclipse-che-restore -n ${NAMESPACE} -o jsonpath='{.status.state}')
Expand Down Expand Up @@ -123,15 +123,15 @@ runTest() {
waitWorkspaceStart
}

prepareTemplates() {
patchTemplates() {
disableUpdateAdminPassword ${TEMPLATES}
setIngressDomain ${TEMPLATES} "$(minikube ip).nip.io"
setCustomOperatorImage ${TEMPLATES} ${OPERATOR_IMAGE}
}

initDefaults
initLatestTemplates
prepareTemplates
patchTemplates
buildCheOperatorImage
copyCheOperatorImageToMinikube
runTest
10 changes: 7 additions & 3 deletions .github/bin/minikube/test-operator-singlehost-gateway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ set -x
set -u

# Get absolute path for root repo directory from github actions context: https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions
export OPERATOR_REPO="${GITHUB_WORKSPACE}"
export OPERATOR_REPO="${GITHUB_WORKSPACE:-}"
if [ -z "${OPERATOR_REPO}" ]; then
SCRIPT=$(readlink -f "${BASH_SOURCE[0]}")
OPERATOR_REPO=$(dirname "$(dirname "$(dirname "$(dirname "$SCRIPT")")")")
fi
source "${OPERATOR_REPO}"/.github/bin/common.sh

# Stop execution on any error
trap "catchFinish" EXIT SIGINT

prepareTemplates() {
patchTemplates() {
disableUpdateAdminPassword ${TEMPLATES}
setCustomOperatorImage ${TEMPLATES} ${OPERATOR_IMAGE}
setServerExposureStrategy ${TEMPLATES} "single-host"
Expand All @@ -37,7 +41,7 @@ runTest() {

initDefaults
initLatestTemplates
prepareTemplates
patchTemplates
buildCheOperatorImage
copyCheOperatorImageToMinikube
runTest
8 changes: 6 additions & 2 deletions .github/bin/minikube/test-operator-singlehost-native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ set -x

# Get absolute path for root repo directory from github actions context: https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions
export OPERATOR_REPO="${GITHUB_WORKSPACE}"
if [ -z "${OPERATOR_REPO}" ]; then
SCRIPT=$(readlink -f "${BASH_SOURCE[0]}")
OPERATOR_REPO=$(dirname "$(dirname "$(dirname "$(dirname "$SCRIPT")")")")
fi
source "${OPERATOR_REPO}"/.github/bin/common.sh

# Stop execution on any error
trap "catchFinish" EXIT SIGINT

prepareTemplates() {
patchTemplates() {
disableUpdateAdminPassword ${TEMPLATES}
setCustomOperatorImage ${TEMPLATES} ${OPERATOR_IMAGE}
setServerExposureStrategy ${TEMPLATES} "single-host"
Expand All @@ -36,7 +40,7 @@ runTest() {

initDefaults
initLatestTemplates
prepareTemplates
patchTemplates
buildCheOperatorImage
copyCheOperatorImageToMinikube
runTest
Loading

0 comments on commit 28d47d9

Please sign in to comment.