Merge pull request #890 from eclipse-che/dwo_dep
feat: Add DevWorkspace as a dependency in che operatorpull/973/head
commit
8d90bb1419
|
|
@ -0,0 +1,57 @@
|
|||
#!/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
|
||||
|
||||
# exit immediately when a command fails
|
||||
set -e
|
||||
# only exit with zero if all commands of the pipeline exit successfully
|
||||
set -o pipefail
|
||||
# error on unset variables
|
||||
set -u
|
||||
|
||||
################################ !!! IMPORTANT !!! ################################
|
||||
########### THIS JOB USE openshift ci operators workflows to run #####################
|
||||
########## More info about how it is configured can be found here: https://docs.ci.openshift.org/docs/how-tos/testing-operator-sdk-operators #############
|
||||
######### Script which install the given bundles from stable-all-namespace https://steps.ci.openshift.org/reference/optional-operators-subscribe ##########
|
||||
######## !!! Related PR in openshift CI is: https://github.com/openshift/release/pull/20610 ##############################################################
|
||||
#######################################################################################################################################################
|
||||
|
||||
|
||||
export OPERATOR_REPO=$(dirname $(dirname $(readlink -f "$0")));
|
||||
source "${OPERATOR_REPO}"/.github/bin/common.sh
|
||||
source "${OPERATOR_REPO}"/.github/bin/oauth-provision.sh
|
||||
|
||||
#Stop execution on any error
|
||||
trap "catchFinish" EXIT SIGINT
|
||||
|
||||
overrideDefaults() {
|
||||
export DEV_WORKSPACE_ENABLE="true"
|
||||
export CHE_EXPOSURE_STRATEGY="single-host"
|
||||
}
|
||||
|
||||
runTests() {
|
||||
# create namespace
|
||||
oc create namespace eclipse-che || true
|
||||
|
||||
# Deploy Eclipse Che applying CR
|
||||
applyOlmCR
|
||||
waitEclipseCheDeployed "${LAST_PACKAGE_VERSION}"
|
||||
|
||||
sleep 10s
|
||||
createWorkspaceDevWorkspaceCheOperator
|
||||
waitAllPodsRunning ${DEVWORKSPACE_CHE_OPERATOR_TEST_NAMESPACE}
|
||||
}
|
||||
|
||||
initDefaults
|
||||
overrideDefaults
|
||||
provisionOpenShiftOAuthUser
|
||||
initStableTemplates "openshift" "stable"
|
||||
runTests
|
||||
|
|
@ -118,6 +118,7 @@ bundle/nightly/eclipse-che-preview-kubernetes/generated
|
|||
bundle/nightly/eclipse-che-preview-openshift/generated
|
||||
bundle/stable/eclipse-che-preview-kubernetes/generated
|
||||
bundle/stable/eclipse-che-preview-openshift/generated
|
||||
bundle/stable-all-namespaces/eclipse-che-preview-openshift/generated
|
||||
|
||||
testbin/setup-envtest.sh
|
||||
|
||||
|
|
|
|||
21
README.md
21
README.md
|
|
@ -133,10 +133,31 @@ spec:
|
|||
|
||||
5. Deploy Che operator:
|
||||
|
||||
|
||||
```bash
|
||||
$ chectl server:deploy --installer=olm --platform=<CHECTL_SUPPORTED_PLATFORM> --catalog-source-yaml <PATH_TO_CUSTOM_CATALOG_SOURCE_YAML> --olm-channel=nightly --package-manifest-name=eclipse-che-preview-<openshift|kubernetes>
|
||||
```
|
||||
|
||||
### Deploy stable Che operator in Cluster Wide Availability
|
||||
|
||||
Eclipse Che introduced a new channel which installs Eclipse Che in AllNamespace mode with Devworkspace Operator like an OLM dependency.
|
||||
More info about DevWorkspace Operator can be found [here](https://github.com/devfile/devworkspace-operator).
|
||||
|
||||
Before installing Eclipse Che using channel `stable-all-namespaces` we need to consider the following:
|
||||
|
||||
* It is not possible to have Eclipse Che installed in single Namespace (currently the default one) and then try to install Che in All Namespace mode using the new channel stable-all-namespaces.
|
||||
* To update to stable-all-namespaces channel you need first to remove all subscriptions created for Che installed from nightly or stable
|
||||
channels. IMPORTANT: Removing subscriptions doesn’t mean Eclipse Che operands(che-server, keycloak or roles) will be removed from the cluster.
|
||||
* DevWorkspace engine will be by default enabled in the new channel.
|
||||
* In case if you have already installed Che with DevWorkspace engine enabled from channels nightly or stable you need to remove all DevWorkspace resources from the cluster following the next [scripts](https://github.com/devfile/devworkspace-operator/blob/main/build/make/deploy.mk#L77).
|
||||
* `stable-all-namespaces` channel is supported only in OpenShift.
|
||||
|
||||
If the OpenShift Cluster already have all these considerations done you can proceed to install the Eclipse Che using stable-all-namespaces channel from OperatorHub or using the new channel you need to perform the following chectl command:
|
||||
|
||||
```bash
|
||||
chectl server:deploy --installer=olm --platform=openshift --olm-channel=stable-all-namespaces
|
||||
```
|
||||
|
||||
### Deploy Che operator using operator-sdk
|
||||
|
||||
> WARNING: Cluster Admin privileges are required
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
FROM scratch
|
||||
|
||||
# Core bundle labels.
|
||||
LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
|
||||
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
|
||||
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
|
||||
LABEL operators.operatorframework.io.bundle.package.v1=eclipse-che-preview-openshift
|
||||
LABEL operators.operatorframework.io.bundle.channels.v1=stable-all-namespaces
|
||||
LABEL operators.operatorframework.io.bundle.channel.default.v1=stable-all-namespaces
|
||||
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.7.1+git
|
||||
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
|
||||
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3
|
||||
|
||||
# Labels for testing.
|
||||
LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1
|
||||
LABEL operators.operatorframework.io.test.config.v1=tests/scorecard/
|
||||
|
||||
# Copy files to locations specified by labels.
|
||||
COPY manifests /manifests/
|
||||
COPY metadata /metadata/
|
||||
COPY tests/scorecard /tests/scorecard/
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,125 @@
|
|||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.4.1
|
||||
creationTimestamp: null
|
||||
name: chebackupserverconfigurations.org.eclipse.che
|
||||
spec:
|
||||
group: org.eclipse.che
|
||||
names:
|
||||
kind: CheBackupServerConfiguration
|
||||
listKind: CheBackupServerConfigurationList
|
||||
plural: chebackupserverconfigurations
|
||||
singular: chebackupserverconfiguration
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
properties:
|
||||
apiVersion:
|
||||
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
|
||||
type: string
|
||||
kind:
|
||||
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
description: CheBackupServerConfigurationSpec defines the desired state of CheBackupServerConfiguration Only one type of backup server is allowed to be configured per CR.
|
||||
properties:
|
||||
awss3:
|
||||
description: Amazon S3 or compatible alternatives.
|
||||
properties:
|
||||
awsAccessKeySecretRef:
|
||||
description: Reference to secret that contains awsAccessKeyId and awsSecretAccessKey keys.
|
||||
type: string
|
||||
hostname:
|
||||
description: Server hostname, defaults to 's3.amazonaws.com'. Might be customized in case of alternative server.
|
||||
type: string
|
||||
port:
|
||||
description: Backup server port. Usually default value is used. Might be customized in case of alternative server.
|
||||
type: integer
|
||||
protocol:
|
||||
description: Protocol to use when connection to the server. Might be customized in case of alternative server.
|
||||
type: string
|
||||
repositoryPasswordSecretRef:
|
||||
description: Holds reference to a secret with restic repository password under 'repo-password' field to encrypt / decrypt its content.
|
||||
type: string
|
||||
repositoryPath:
|
||||
description: Bucket name and repository, e.g. bucket/repo
|
||||
type: string
|
||||
required:
|
||||
- awsAccessKeySecretRef
|
||||
- repositoryPasswordSecretRef
|
||||
- repositoryPath
|
||||
type: object
|
||||
rest:
|
||||
description: Rest backup server configuration.
|
||||
properties:
|
||||
credentialsSecretRef:
|
||||
description: Secret that contains username and password fields to login into restic server. Note, each repository is encrypted with own password. See ResticRepoPasswordSecretRef field.
|
||||
type: string
|
||||
hostname:
|
||||
description: Backup server host
|
||||
type: string
|
||||
port:
|
||||
description: Backup server port
|
||||
type: integer
|
||||
protocol:
|
||||
description: Protocol to use when connection to the server Defaults to https.
|
||||
type: string
|
||||
repositoryPasswordSecretRef:
|
||||
description: Holds reference to a secret with restic repository password under 'repo-password' field to encrypt / decrypt its content.
|
||||
type: string
|
||||
repositoryPath:
|
||||
description: Restic repository path
|
||||
type: string
|
||||
required:
|
||||
- hostname
|
||||
- repositoryPasswordSecretRef
|
||||
type: object
|
||||
sftp:
|
||||
description: Sftp backup server configuration.
|
||||
properties:
|
||||
hostname:
|
||||
description: Backup server host
|
||||
type: string
|
||||
port:
|
||||
description: Backup server port
|
||||
type: integer
|
||||
repositoryPasswordSecretRef:
|
||||
description: Holds reference to a secret with restic repository password under 'repo-password' field to encrypt / decrypt its content.
|
||||
type: string
|
||||
repositoryPath:
|
||||
description: Restic repository path, relative or absolute, e.g. /srv/repo
|
||||
type: string
|
||||
sshKeySecretRef:
|
||||
description: Private ssh key under 'ssh-privatekey' field for passwordless login
|
||||
type: string
|
||||
username:
|
||||
description: User login on the remote server
|
||||
type: string
|
||||
required:
|
||||
- hostname
|
||||
- repositoryPasswordSecretRef
|
||||
- repositoryPath
|
||||
- sshKeySecretRef
|
||||
- username
|
||||
type: object
|
||||
type: object
|
||||
status:
|
||||
description: CheBackupServerConfigurationStatus defines the observed state of CheBackupServerConfiguration
|
||||
type: object
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
status:
|
||||
acceptedNames:
|
||||
kind: ""
|
||||
plural: ""
|
||||
conditions: []
|
||||
storedVersions: []
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.4.1
|
||||
creationTimestamp: null
|
||||
name: checlusterbackups.org.eclipse.che
|
||||
spec:
|
||||
group: org.eclipse.che
|
||||
names:
|
||||
kind: CheClusterBackup
|
||||
listKind: CheClusterBackupList
|
||||
plural: checlusterbackups
|
||||
singular: checlusterbackup
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
properties:
|
||||
apiVersion:
|
||||
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
|
||||
type: string
|
||||
kind:
|
||||
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
description: CheClusterBackupSpec defines the desired state of CheClusterBackup
|
||||
properties:
|
||||
backupServerConfigRef:
|
||||
description: Name of custom resource with a backup server configuration to use for this backup. Note, UseInternalBackupServer field can configure internal backup server automatically.
|
||||
type: string
|
||||
useInternalBackupServer:
|
||||
description: Automatically setup pod with REST backup server and use the server in this configuration. Note, this flag takes precedence and will overwrite existing backup server configuration.
|
||||
type: boolean
|
||||
type: object
|
||||
status:
|
||||
description: CheClusterBackupStatus defines the observed state of CheClusterBackup
|
||||
properties:
|
||||
message:
|
||||
description: Message explaining the state of the backup or an error message
|
||||
type: string
|
||||
snapshotId:
|
||||
description: Last backup snapshot ID
|
||||
type: string
|
||||
stage:
|
||||
description: Describes backup progress
|
||||
type: string
|
||||
state:
|
||||
description: 'Backup progress state: InProgress, Failed, Succeeded'
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
status:
|
||||
acceptedNames:
|
||||
kind: ""
|
||||
plural: ""
|
||||
conditions: []
|
||||
storedVersions: []
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.4.1
|
||||
creationTimestamp: null
|
||||
name: checlusterrestores.org.eclipse.che
|
||||
spec:
|
||||
group: org.eclipse.che
|
||||
names:
|
||||
kind: CheClusterRestore
|
||||
listKind: CheClusterRestoreList
|
||||
plural: checlusterrestores
|
||||
singular: checlusterrestore
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
properties:
|
||||
apiVersion:
|
||||
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
|
||||
type: string
|
||||
kind:
|
||||
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
description: CheClusterRestoreSpec defines the desired state of CheClusterRestore
|
||||
properties:
|
||||
backupServerConfigRef:
|
||||
description: Name of custom resource with a backup server configuration to use for this restore. Can be omitted if only one server configuration object exists within the namespace.
|
||||
type: string
|
||||
snapshotId:
|
||||
description: If omitted, latest snapshot will be used.
|
||||
type: string
|
||||
type: object
|
||||
status:
|
||||
description: CheClusterRestoreStatus defines the observed state of CheClusterRestore
|
||||
properties:
|
||||
message:
|
||||
description: Restore result or error message
|
||||
type: string
|
||||
stage:
|
||||
description: Describes phase of restore progress
|
||||
type: string
|
||||
state:
|
||||
description: 'Restore progress state: InProgress, Failed, Succeeded'
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
status:
|
||||
acceptedNames:
|
||||
kind: ""
|
||||
plural: ""
|
||||
conditions: []
|
||||
storedVersions: []
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,15 @@
|
|||
annotations:
|
||||
# Core bundle annotations.
|
||||
operators.operatorframework.io.bundle.mediatype.v1: registry+v1
|
||||
operators.operatorframework.io.bundle.manifests.v1: manifests/
|
||||
operators.operatorframework.io.bundle.metadata.v1: metadata/
|
||||
operators.operatorframework.io.bundle.package.v1: eclipse-che-preview-openshift
|
||||
operators.operatorframework.io.bundle.channels.v1: stable-all-namespaces
|
||||
operators.operatorframework.io.bundle.channel.default.v1: stable-all-namespaces
|
||||
operators.operatorframework.io.metrics.builder: operator-sdk-v1.6.1+git
|
||||
operators.operatorframework.io.metrics.mediatype.v1: metrics+v1
|
||||
operators.operatorframework.io.metrics.project_layout: go.kubebuilder.io/v3
|
||||
|
||||
# Annotations for testing.
|
||||
operators.operatorframework.io.test.mediatype.v1: scorecard+v1
|
||||
operators.operatorframework.io.test.config.v1: tests/scorecard/
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
dependencies:
|
||||
- type: olm.package
|
||||
value:
|
||||
packageName: devworkspace-operator
|
||||
version: ">=0.8.0"
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
apiVersion: scorecard.operatorframework.io/v1alpha3
|
||||
kind: Configuration
|
||||
metadata:
|
||||
name: config
|
||||
stages:
|
||||
- parallel: true
|
||||
tests:
|
||||
- entrypoint:
|
||||
- scorecard-test
|
||||
- basic-check-spec
|
||||
image: quay.io/operator-framework/scorecard-test:v1.7.1
|
||||
labels:
|
||||
suite: basic
|
||||
test: basic-check-spec-test
|
||||
- entrypoint:
|
||||
- scorecard-test
|
||||
- olm-bundle-validation
|
||||
image: quay.io/operator-framework/scorecard-test:v1.7.1
|
||||
labels:
|
||||
suite: olm
|
||||
test: olm-bundle-validation-test
|
||||
- entrypoint:
|
||||
- scorecard-test
|
||||
- olm-crds-have-validation
|
||||
image: quay.io/operator-framework/scorecard-test:v1.7.1
|
||||
labels:
|
||||
suite: olm
|
||||
test: olm-crds-have-validation-test
|
||||
- entrypoint:
|
||||
- scorecard-test
|
||||
- olm-crds-have-resources
|
||||
image: quay.io/operator-framework/scorecard-test:v1.7.1
|
||||
labels:
|
||||
suite: olm
|
||||
test: olm-crds-have-resources-test
|
||||
- entrypoint:
|
||||
- scorecard-test
|
||||
- olm-spec-descriptors
|
||||
image: quay.io/operator-framework/scorecard-test:v1.7.1
|
||||
labels:
|
||||
suite: olm
|
||||
test: olm-spec-descriptors-test
|
||||
- entrypoint:
|
||||
- scorecard-test
|
||||
- olm-status-descriptors
|
||||
image: quay.io/operator-framework/scorecard-test:v1.7.1
|
||||
labels:
|
||||
suite: olm
|
||||
test: olm-status-descriptors-test
|
||||
|
|
@ -29,6 +29,7 @@ init() {
|
|||
BUILDX_PLATFORMS="linux/amd64,linux/ppc64le"
|
||||
DEV_WORKSPACE_CONTROLLER_VERSION="main"
|
||||
DEV_WORKSPACE_CHE_OPERATOR_VERSION="main"
|
||||
STABLE_CHANNELS=("stable-all-namespaces" "stable")
|
||||
|
||||
if [[ $# -lt 1 ]]; then usage; exit; fi
|
||||
|
||||
|
|
@ -48,7 +49,6 @@ init() {
|
|||
esac
|
||||
shift 1
|
||||
done
|
||||
|
||||
[ -z "$QUAY_ECLIPSE_CHE_USERNAME" ] && echo "[ERROR] QUAY_ECLIPSE_CHE_USERNAME is not set" && exit 1
|
||||
[ -z "$QUAY_ECLIPSE_CHE_PASSWORD" ] && echo "[ERROR] QUAY_ECLIPSE_CHE_PASSWORD is not set" && exit 1
|
||||
command -v operator-courier >/dev/null 2>&1 || { echo "[ERROR] operator-courier is not installed. Abort."; exit 1; }
|
||||
|
|
@ -227,27 +227,30 @@ updateVersionFile() {
|
|||
releaseOlmFiles() {
|
||||
echo "[INFO] releaseOlmFiles :: Release OLM files"
|
||||
echo "[INFO] releaseOlmFiles :: Launch 'olm/release-olm-files.sh' script"
|
||||
cd $RELEASE_DIR/olm
|
||||
. release-olm-files.sh --release-version $RELEASE --dev-workspace-controller-version $DEV_WORKSPACE_CONTROLLER_VERSION --dev-workspace-che-operator-version $DEV_WORKSPACE_CHE_OPERATOR_VERSION
|
||||
cd $RELEASE_DIR
|
||||
for channel in "${STABLE_CHANNELS[@]}"
|
||||
do
|
||||
cd $RELEASE_DIR/olm
|
||||
. release-olm-files.sh --release-version $RELEASE --channel $channel --dev-workspace-controller-version $DEV_WORKSPACE_CONTROLLER_VERSION --dev-workspace-che-operator-version $DEV_WORKSPACE_CHE_OPERATOR_VERSION
|
||||
cd $RELEASE_DIR
|
||||
local openshift=$RELEASE_DIR/bundle/$channel/eclipse-che-preview-openshift/manifests
|
||||
|
||||
local openshift=$RELEASE_DIR/bundle/stable/eclipse-che-preview-openshift/manifests
|
||||
local kubernetes=$RELEASE_DIR/bundle/stable/eclipse-che-preview-kubernetes/manifests
|
||||
echo "[INFO] releaseOlmFiles :: Validate changes"
|
||||
grep -q "version: "$RELEASE $openshift/che-operator.clusterserviceversion.yaml
|
||||
if [[ $channel == "stable" ]];then
|
||||
local kubernetes=$RELEASE_DIR/bundle/$channel/eclipse-che-preview-kubernetes/manifests
|
||||
grep -q "version: "$RELEASE $kubernetes/che-operator.clusterserviceversion.yaml
|
||||
|
||||
echo "[INFO] releaseOlmFiles :: Validate changes"
|
||||
grep -q "version: "$RELEASE $openshift/che-operator.clusterserviceversion.yaml
|
||||
grep -q "version: "$RELEASE $kubernetes/che-operator.clusterserviceversion.yaml
|
||||
|
||||
test -f $kubernetes/org_v1_che_crd.yaml
|
||||
test -f $kubernetes/org.eclipse.che_chebackupserverconfigurations_crd.yaml
|
||||
test -f $kubernetes/org.eclipse.che_checlusterbackups_crd.yaml
|
||||
test -f $kubernetes/org.eclipse.che_checlusterrestores_crd.yaml
|
||||
|
||||
test -f $openshift/org_v1_che_crd.yaml
|
||||
test -f $openshift/org.eclipse.che_chebackupserverconfigurations_crd.yaml
|
||||
test -f $openshift/org.eclipse.che_checlusterbackups_crd.yaml
|
||||
test -f $openshift/org.eclipse.che_checlusterrestores_crd.yaml
|
||||
test -f $kubernetes/org_v1_che_crd.yaml
|
||||
test -f $kubernetes/org.eclipse.che_chebackupserverconfigurations_crd.yaml
|
||||
test -f $kubernetes/org.eclipse.che_checlusterbackups_crd.yaml
|
||||
test -f $kubernetes/org.eclipse.che_checlusterrestores_crd.yaml
|
||||
fi
|
||||
|
||||
test -f $openshift/org_v1_che_crd.yaml
|
||||
test -f $openshift/org.eclipse.che_chebackupserverconfigurations_crd.yaml
|
||||
test -f $openshift/org.eclipse.che_checlusterbackups_crd.yaml
|
||||
test -f $openshift/org.eclipse.che_checlusterrestores_crd.yaml
|
||||
done
|
||||
echo "[INFO] releaseOlmFiles :: Commit changes"
|
||||
if git status --porcelain; then
|
||||
git add -A || true # add new generated CSV files in olm/ folder
|
||||
|
|
@ -259,6 +262,7 @@ 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 "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"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ CURRENT_DIR=$(pwd)
|
|||
SCRIPT=$(readlink -f "${BASH_SOURCE[0]}")
|
||||
BASE_DIR=$(cd "$(dirname "$0")"; pwd)
|
||||
PLATFORMS="kubernetes,openshift"
|
||||
STABLE_CHANNELS=("stable-all-namespaces" "stable")
|
||||
source "${BASE_DIR}/check-yq.sh"
|
||||
|
||||
base_branch="main"
|
||||
|
|
@ -108,38 +109,61 @@ do
|
|||
folderToUpdate="${communityOperatorsLocalGitFolder}/${platformSubFolder}/eclipse-che"
|
||||
destinationPackageFilePath="${folderToUpdate}/eclipse-che.package.yaml"
|
||||
|
||||
lastPublishedPackageVersion=$(yq -r '.channels[] | select(.name == "stable") | .currentCSV' "${destinationPackageFilePath}" | sed -e "s/eclipse-che.v//")
|
||||
echo
|
||||
echo " - Last package pre-release version of local package: ${lastPackagePreReleaseVersion}"
|
||||
echo " - Last package release version of cloned 'community-operators' repository: ${lastPublishedPackageVersion}"
|
||||
if [[ "${lastPackagePreReleaseVersion}" == "${lastPublishedPackageVersion}" ]] && [[ "${FORCE}" == "" ]]; then
|
||||
echo "#### ERROR ####"
|
||||
echo "Release ${lastPackagePreReleaseVersion} already exists in the '${platformSubFolder}/eclipse-che' package !"
|
||||
exit 1
|
||||
fi
|
||||
for channel in "${STABLE_CHANNELS[@]}"
|
||||
do
|
||||
if [[ $channel == "stable-all-namespaces" && $platform == "kubernetes" ]];then
|
||||
continue
|
||||
fi
|
||||
lastPackagePreReleaseVersion=$(yq -r '.channels[] | select(.name == "'$channel'") | .currentCSV' "${sourcePackageFilePath}" | sed -e "s/${packageName}.v//")
|
||||
lastPublishedPackageVersion=$(yq -r '.channels[] | select(.name == "'$channel'") | .currentCSV' "${destinationPackageFilePath}" | sed -e "s/eclipse-che.v//")
|
||||
if [[ $channel == "stable-all-namespaces" && -z $lastPublishedPackageVersion ]];then
|
||||
lastPublishedPackageVersion=$lastPackagePreReleaseVersion
|
||||
fi
|
||||
|
||||
echo " => will create release '${lastPackagePreReleaseVersion}' in the following package folder :'${folderToUpdate}'"
|
||||
echo
|
||||
echo " - Last package pre-release version of local package: ${lastPackagePreReleaseVersion}"
|
||||
echo " - Last package release version of cloned 'community-operators' repository: ${lastPublishedPackageVersion}"
|
||||
if [[ "${lastPackagePreReleaseVersion}" == "${lastPublishedPackageVersion}" ]] && [[ "${FORCE}" == "" ]]; then
|
||||
echo "#### ERROR ####"
|
||||
echo "Release ${lastPackagePreReleaseVersion} already exists in the '${platformSubFolder}/eclipse-che' package !"
|
||||
exit 1
|
||||
fi
|
||||
echo $lastPackagePreReleaseVersion
|
||||
echo $platform
|
||||
echo " => will create release '${lastPackagePreReleaseVersion}' in the following package folder :'${folderToUpdate}'"
|
||||
|
||||
mkdir -p "${folderToUpdate}/${lastPackagePreReleaseVersion}"
|
||||
sed \
|
||||
-e "/^ replaces: ${packageName}.v.*/d" \
|
||||
-e "/^ version: ${lastPackagePreReleaseVersion}/i\ \ replaces: eclipse-che.v${lastPublishedPackageVersion}" \
|
||||
-e "s/${packageName}/eclipse-che/" \
|
||||
"${packageBaseFolderPath}/${lastPackagePreReleaseVersion}/che-operator.clusterserviceversion.yaml" \
|
||||
> "${folderToUpdate}/${lastPackagePreReleaseVersion}/eclipse-che.v${lastPackagePreReleaseVersion}.clusterserviceversion.yaml"
|
||||
mkdir -p "${folderToUpdate}/${lastPackagePreReleaseVersion}"
|
||||
sed \
|
||||
-e "/^ replaces: ${packageName}.v.*/d" \
|
||||
-e "/^ version: ${lastPackagePreReleaseVersion}/i\ \ replaces: eclipse-che.v${lastPublishedPackageVersion}" \
|
||||
-e "s/${packageName}/eclipse-che/" \
|
||||
"${packageBaseFolderPath}/${lastPackagePreReleaseVersion}/che-operator.clusterserviceversion.yaml" \
|
||||
> "${folderToUpdate}/${lastPackagePreReleaseVersion}/eclipse-che.v${lastPackagePreReleaseVersion}.clusterserviceversion.yaml"
|
||||
|
||||
echo
|
||||
echo " - Update the CRD files"
|
||||
cp "${packageBaseFolderPath}/${lastPackagePreReleaseVersion}/org_v1_che_crd.yaml" \
|
||||
"${folderToUpdate}/${lastPackagePreReleaseVersion}/checlusters.org.eclipse.che.crd.yaml"
|
||||
cp "${packageBaseFolderPath}/${lastPackagePreReleaseVersion}/org.eclipse.che_chebackupserverconfigurations_crd.yaml" "${folderToUpdate}/${lastPackagePreReleaseVersion}/org.eclipse.che_chebackupserverconfigurations_crd.yaml"
|
||||
cp "${packageBaseFolderPath}/${lastPackagePreReleaseVersion}/org.eclipse.che_checlusterbackups_crd.yaml" "${folderToUpdate}/${lastPackagePreReleaseVersion}/org.eclipse.che_checlusterbackups_crd.yaml"
|
||||
cp "${packageBaseFolderPath}/${lastPackagePreReleaseVersion}/org.eclipse.che_checlusterrestores_crd.yaml" "${folderToUpdate}/${lastPackagePreReleaseVersion}/org.eclipse.che_checlusterrestores_crd.yaml"
|
||||
echo
|
||||
echo " - Update 'stable' channel with new release in the package descriptor: ${destinationPackageFilePath}"
|
||||
sed -e "s/${lastPublishedPackageVersion}/${lastPackagePreReleaseVersion}/" "${destinationPackageFilePath}" > "${destinationPackageFilePath}.new"
|
||||
mv "${destinationPackageFilePath}.new" "${destinationPackageFilePath}"
|
||||
echo
|
||||
echo
|
||||
echo " - Update the CRD files"
|
||||
cp "${packageBaseFolderPath}/${lastPackagePreReleaseVersion}/org_v1_che_crd.yaml" \
|
||||
"${folderToUpdate}/${lastPackagePreReleaseVersion}/checlusters.org.eclipse.che.crd.yaml"
|
||||
cp "${packageBaseFolderPath}/${lastPackagePreReleaseVersion}/org.eclipse.che_chebackupserverconfigurations_crd.yaml" "${folderToUpdate}/${lastPackagePreReleaseVersion}/org.eclipse.che_chebackupserverconfigurations_crd.yaml"
|
||||
cp "${packageBaseFolderPath}/${lastPackagePreReleaseVersion}/org.eclipse.che_checlusterbackups_crd.yaml" "${folderToUpdate}/${lastPackagePreReleaseVersion}/org.eclipse.che_checlusterbackups_crd.yaml"
|
||||
cp "${packageBaseFolderPath}/${lastPackagePreReleaseVersion}/org.eclipse.che_checlusterrestores_crd.yaml" "${folderToUpdate}/${lastPackagePreReleaseVersion}/org.eclipse.che_checlusterrestores_crd.yaml"
|
||||
echo
|
||||
echo " - Update 'stable' channel with new release in the package descriptor: ${destinationPackageFilePath}"
|
||||
sed -e "s/${lastPublishedPackageVersion}/${lastPackagePreReleaseVersion}/" "${destinationPackageFilePath}" > "${destinationPackageFilePath}.new"
|
||||
echo
|
||||
|
||||
# Append to community operators the stable channel csv version: https://github.com/operator-framework/community-operators/blob/master/community-operators/eclipse-che/eclipse-che.package.yaml
|
||||
if [[ $channel == "stable" ]]; then
|
||||
mv "${destinationPackageFilePath}.new" "${destinationPackageFilePath}"
|
||||
fi
|
||||
|
||||
# Append to community operators the stable-all-namespaces channel csv version: https://github.com/operator-framework/community-operators/blob/master/community-operators/eclipse-che/eclipse-che.package.yaml
|
||||
if [[ $channel == "stable-all-namespaces" ]]; then
|
||||
yq -riY ".channels[1] = { \"currentCSV\": \"eclipse-che.v${lastPackagePreReleaseVersion}\", \"name\": \"$channel\"}" $destinationPackageFilePath
|
||||
fi
|
||||
done
|
||||
# Make by default stable channel in the community operators eclipse-che.package.yaml
|
||||
yq -Yi '.defaultChannel |= "stable"' ${destinationPackageFilePath}
|
||||
|
||||
# NOTE: if you update this file, you need to submit a PR against these two files:
|
||||
# https://github.com/redhat-openshift-ecosystem/community-operators-prod/blob/main/operators/eclipse-che/ci.yaml
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ set -e
|
|||
while [[ "$#" -gt 0 ]]; do
|
||||
case $1 in
|
||||
'--release-version') RELEASE=$2; shift 1;;
|
||||
'--channel') CHANNEL=$2; shift 1;;
|
||||
'--dev-workspace-controller-version') DEV_WORKSPACE_CONTROLLER_VERSION=$2; shift 1;;
|
||||
'--dev-workspace-che-operator-version') DEV_WORKSPACE_CHE_OPERATOR_VERSION=$2; shift 1;;
|
||||
esac
|
||||
|
|
@ -23,6 +24,7 @@ done
|
|||
|
||||
OPERATOR_DIR=$(dirname $(dirname $(readlink -f "${BASH_SOURCE[0]}")))
|
||||
BASE_DIR="${OPERATOR_DIR}/olm"
|
||||
|
||||
source ${BASE_DIR}/check-yq.sh
|
||||
|
||||
command -v pysemver >/dev/null 2>&1 || { echo "[ERROR] pysemver is not installed. Abort."; exit 1; }
|
||||
|
|
@ -84,18 +86,22 @@ if [[ -z "$RELEASE" ]] || [[ -z "$RELEASE" ]] || [[ -z "$RELEASE" ]]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
for platform in 'kubernetes' 'openshift'
|
||||
do
|
||||
source ${BASE_DIR}/olm.sh
|
||||
|
||||
echo "[INFO] Creating release '${RELEASE}' for platform '${platform}'"
|
||||
|
||||
if [[ ${CHANNEL} == "stable-all-namespaces" ]] && [[ ${platform} == "kubernetes" ]];then
|
||||
continue
|
||||
fi
|
||||
|
||||
NIGHTLY_BUNDLE_PATH=$(getBundlePath "${platform}" "nightly")
|
||||
LAST_NIGHTLY_CSV="${NIGHTLY_BUNDLE_PATH}/manifests/che-operator.clusterserviceversion.yaml"
|
||||
lastPackageNightlyVersion=$(yq -r ".spec.version" "${LAST_NIGHTLY_CSV}")
|
||||
echo "[INFO] Last package nightly version: ${lastPackageNightlyVersion}"
|
||||
|
||||
STABLE_BUNDLE_PATH=$(getBundlePath "${platform}" "stable")
|
||||
STABLE_BUNDLE_PATH=$(getBundlePath "${platform}" $CHANNEL)
|
||||
RELEASE_CSV="${STABLE_BUNDLE_PATH}/manifests/che-operator.clusterserviceversion.yaml"
|
||||
RELEASE_CHE_CRD="${STABLE_BUNDLE_PATH}/manifests/org_v1_che_crd.yaml"
|
||||
RELEASE_CHE_BACKUP_SERVER_CONFIGURATION_CRD="${STABLE_BUNDLE_PATH}/manifests/org.eclipse.che_chebackupserverconfigurations_crd.yaml"
|
||||
|
|
@ -125,32 +131,52 @@ do
|
|||
-e "s/${lastPackageNightlyVersion}/${RELEASE}/" \
|
||||
-e "s/createdAt:.*$/createdAt: \"$(date -u +%FT%TZ)\"/" "${LAST_NIGHTLY_CSV}" > "${RELEASE_CSV}"
|
||||
|
||||
if [[ ${CHANNEL} == "stable-all-namespaces" ]];then
|
||||
# Set by default devworkspace enabled
|
||||
CR_SAMPLE=$(yq -r ".metadata.annotations.\"alm-examples\"" "${RELEASE_CSV}" | yq -r ".[0] | .spec.devWorkspace.enable |= true | [.]" | sed -r 's/"/\\"/g')
|
||||
yq -rY " (.metadata.annotations.\"alm-examples\") = \"${CR_SAMPLE}\"" "${RELEASE_CSV}" > "${RELEASE_CSV}.old"
|
||||
mv "${RELEASE_CSV}.old" "${RELEASE_CSV}"
|
||||
|
||||
# Move the suggested namespace to openshift-operators.
|
||||
sed -ri 's|operatorframework.io/suggested-namespace: eclipse-che|operatorframework.io/suggested-namespace: openshift-operators|' "${RELEASE_CSV}"
|
||||
|
||||
# Set stable-all-namespaces versions
|
||||
yq -Yi '.spec.replaces |= "'${packageName}'.v'$LAST_RELEASE_VERSION'-all-namespaces"' ${RELEASE_CSV}
|
||||
yq -Yi '.spec.version |= "'${RELEASE}'-all-namespaces"' ${RELEASE_CSV}
|
||||
yq -Yi '.metadata.name |= "eclipse-che-preview-openshift.v'${RELEASE}'-all-namespaces"' ${RELEASE_CSV}
|
||||
|
||||
# Change the install Mode to AllNamespaces by default
|
||||
yq -Yi '.spec.installModes[] |= if .type=="OwnNamespace" then .supported |= false else . end' ${RELEASE_CSV}
|
||||
yq -Yi '.spec.installModes[] |= if .type=="SingleNamespace" then .supported |= false else . end' ${RELEASE_CSV}
|
||||
yq -Yi '.spec.installModes[] |= if .type=="MultiNamespace" then .supported |= false else . end' ${RELEASE_CSV}
|
||||
yq -Yi '.spec.installModes[] |= if .type=="AllNamespaces" then .supported |= true else . end' ${RELEASE_CSV}
|
||||
fi
|
||||
|
||||
cp "${NIGHTLY_BUNDLE_PATH}/manifests/org_v1_che_crd.yaml" "${RELEASE_CHE_CRD}"
|
||||
cp "${NIGHTLY_BUNDLE_PATH}/manifests/org.eclipse.che_chebackupserverconfigurations_crd.yaml" "${RELEASE_CHE_BACKUP_SERVER_CONFIGURATION_CRD}"
|
||||
cp "${NIGHTLY_BUNDLE_PATH}/manifests/org.eclipse.che_checlusterbackups_crd.yaml" "${RELEASE_CHE_BACKUP_CRD}"
|
||||
cp "${NIGHTLY_BUNDLE_PATH}/manifests/org.eclipse.che_checlusterrestores_crd.yaml" "${RELEASE_CHE_RESTORE_CRD}"
|
||||
cp "${NIGHTLY_BUNDLE_PATH}/manifests/org.eclipse.che_chebackupserverconfigurations.yaml" "${RELEASE_CHE_BACKUP_SERVER_CONFIGURATION_CRD}"
|
||||
cp "${NIGHTLY_BUNDLE_PATH}/manifests/org.eclipse.che_checlusterbackups.yaml" "${RELEASE_CHE_BACKUP_CRD}"
|
||||
cp "${NIGHTLY_BUNDLE_PATH}/manifests/org.eclipse.che_checlusterrestores.yaml" "${RELEASE_CHE_RESTORE_CRD}"
|
||||
cp -rf "${NIGHTLY_BUNDLE_PATH}/bundle.Dockerfile" "${STABLE_BUNDLE_PATH}"
|
||||
cp -rf "${NIGHTLY_BUNDLE_PATH}/metadata" "${STABLE_BUNDLE_PATH}"
|
||||
cp -rf "${NIGHTLY_BUNDLE_PATH}/tests" "${STABLE_BUNDLE_PATH}"
|
||||
|
||||
ANNOTATION_METADATA_YAML="${STABLE_BUNDLE_PATH}/metadata/annotations.yaml"
|
||||
sed \
|
||||
-e 's/operators.operatorframework.io.bundle.channels.v1: *nightly/operators.operatorframework.io.bundle.channels.v1: stable/' \
|
||||
-e 's/operators.operatorframework.io.bundle.channel.default.v1: *nightly/operators.operatorframework.io.bundle.channel.default.v1: stable/' \
|
||||
-e 's/operators.operatorframework.io.bundle.channels.v1: *nightly/operators.operatorframework.io.bundle.channels.v1: '$CHANNEL'/' \
|
||||
-e 's/operators.operatorframework.io.bundle.channel.default.v1: *nightly/operators.operatorframework.io.bundle.channel.default.v1: '$CHANNEL'/' \
|
||||
-i "${ANNOTATION_METADATA_YAML}"
|
||||
|
||||
BUNDLE_DOCKERFILE="${STABLE_BUNDLE_PATH}/bundle.Dockerfile"
|
||||
sed \
|
||||
-e 's/LABEL operators.operatorframework.io.bundle.channels.v1=nightly/LABEL operators.operatorframework.io.bundle.channels.v1=stable/' \
|
||||
-e 's/LABEL operators.operatorframework.io.bundle.channel.default.v1=nightly/LABEL operators.operatorframework.io.bundle.channel.default.v1=stable/' \
|
||||
-e 's/LABEL operators.operatorframework.io.bundle.channels.v1=nightly/LABEL operators.operatorframework.io.bundle.channels.v1='$CHANNEL'/' \
|
||||
-e 's/LABEL operators.operatorframework.io.bundle.channel.default.v1=nightly/LABEL operators.operatorframework.io.bundle.channel.default.v1='$CHANNEL'/' \
|
||||
-i "${BUNDLE_DOCKERFILE}"
|
||||
|
||||
pushd "${CURRENT_DIR}" || true
|
||||
|
||||
source ${BASE_DIR}/addDigests.sh -w ${BASE_DIR} \
|
||||
-t "${RELEASE}" \
|
||||
-s "${STABLE_BUNDLE_PATH}/manifests/che-operator.clusterserviceversion.yaml" \
|
||||
-o "${OPERATOR_DIR}/config/manager/manager.yaml"
|
||||
|
||||
popd || true
|
||||
|
||||
if [[ -n "${PRE_RELEASE_CSV}" ]] && [[ -n "${PRE_RELEASE_CHE_CRD}" ]]; then
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
orgv1 "github.com/eclipse-che/che-operator/api/v1"
|
||||
"github.com/eclipse-che/che-operator/pkg/deploy"
|
||||
|
|
@ -39,13 +40,15 @@ import (
|
|||
|
||||
var (
|
||||
DevWorkspaceNamespace = "devworkspace-controller"
|
||||
DevWorkspaceCheNamespace = "devworkspace-che"
|
||||
DevWorkspaceWebhookName = "controller.devfile.io"
|
||||
DevWorkspaceServiceAccount = "devworkspace-controller-serviceaccount"
|
||||
DevWorkspaceService = "devworkspace-controller-manager-service"
|
||||
DevWorkspaceDeploymentName = "devworkspace-controller-manager"
|
||||
SubscriptionResourceName = "subscriptions"
|
||||
CheManagerResourcename = "chemanagers"
|
||||
|
||||
SubscriptionResourceName = "subscriptions"
|
||||
CheManagerResourcename = "chemanagers"
|
||||
ClusterServiceVersionResourceName = "clusterserviceversions"
|
||||
DevWorkspaceCSVNameWithouVersion = "devworkspace-operator"
|
||||
|
||||
OpenshiftDevWorkspaceTemplatesPath = "/tmp/devworkspace-operator/templates/deployment/openshift/objects"
|
||||
OpenshiftDevWorkspaceCheTemplatesPath = "/tmp/devworkspace-che-operator/templates/deployment/openshift/objects"
|
||||
|
|
@ -113,6 +116,12 @@ func ReconcileDevWorkspace(deployContext *deploy.DeployContext) (bool, error) {
|
|||
return true, nil
|
||||
}
|
||||
|
||||
// Check if exists devworkspace operator csv is already installed
|
||||
devWorkspaceOperatorCSVExists := isDevWorkspaceOperatorCSVExists(deployContext)
|
||||
if devWorkspaceOperatorCSVExists {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// do nothing if dev workspace is disabled
|
||||
if !deployContext.CheCluster.Spec.DevWorkspace.Enable {
|
||||
return true, nil
|
||||
|
|
@ -152,6 +161,27 @@ func ReconcileDevWorkspace(deployContext *deploy.DeployContext) (bool, error) {
|
|||
return true, nil
|
||||
}
|
||||
|
||||
func isDevWorkspaceOperatorCSVExists(deployContext *deploy.DeployContext) bool {
|
||||
// If clusterserviceversions resource doesn't exist in cluster DWO as well will not be present
|
||||
if !util.HasK8SResourceObject(deployContext.ClusterAPI.DiscoveryClient, ClusterServiceVersionResourceName) {
|
||||
return false
|
||||
}
|
||||
|
||||
csvList := &operatorsv1alpha1.ClusterServiceVersionList{}
|
||||
err := deployContext.ClusterAPI.Client.List(context.TODO(), csvList, &client.ListOptions{})
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, csv := range csvList.Items {
|
||||
if strings.Contains(csv.Name, DevWorkspaceCSVNameWithouVersion) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func checkWebTerminalSubscription(deployContext *deploy.DeployContext) error {
|
||||
// If subscriptions resource doesn't exist in cluster WTO as well will not be present
|
||||
if !util.HasK8SResourceObject(deployContext.ClusterAPI.DiscoveryClient, SubscriptionResourceName) {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
package devworkspace
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
orgv1 "github.com/eclipse-che/che-operator/api/v1"
|
||||
"github.com/eclipse-che/che-operator/pkg/deploy"
|
||||
"github.com/eclipse-che/che-operator/pkg/util"
|
||||
|
|
@ -21,10 +23,15 @@ import (
|
|||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
fakeDiscovery "k8s.io/client-go/discovery/fake"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
const (
|
||||
DevWorkspaceCSVName = "devworkspace-operator.v0.6.0"
|
||||
)
|
||||
|
||||
func TestReconcileDevWorkspace(t *testing.T) {
|
||||
type testCase struct {
|
||||
name string
|
||||
|
|
@ -109,6 +116,7 @@ func TestReconcileDevWorkspace(t *testing.T) {
|
|||
t.Run(testCase.name, func(t *testing.T) {
|
||||
deployContext := deploy.GetTestDeployContext(testCase.cheCluster, []runtime.Object{})
|
||||
deployContext.ClusterAPI.Scheme.AddKnownTypes(operatorsv1alpha1.SchemeGroupVersion, &operatorsv1alpha1.Subscription{})
|
||||
deployContext.ClusterAPI.Scheme.AddKnownTypes(operatorsv1alpha1.SchemeGroupVersion, &operatorsv1alpha1.ClusterServiceVersion{})
|
||||
deployContext.ClusterAPI.DiscoveryClient.(*fakeDiscovery.FakeDiscovery).Fake.Resources = []*metav1.APIResourceList{
|
||||
{
|
||||
APIResources: []metav1.APIResource{
|
||||
|
|
@ -180,6 +188,60 @@ func TestReconcileDevWorkspaceShouldThrowErrorIfWebTerminalSubscriptionExists(t
|
|||
}
|
||||
}
|
||||
|
||||
func TestReconcileDevWorkspaceCheckIfCSVExists(t *testing.T) {
|
||||
cheCluster := &orgv1.CheCluster{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: "eclipse-che",
|
||||
},
|
||||
Spec: orgv1.CheClusterSpec{
|
||||
DevWorkspace: orgv1.CheClusterSpecDevWorkspace{
|
||||
Enable: true,
|
||||
},
|
||||
Auth: orgv1.CheClusterSpecAuth{
|
||||
OpenShiftoAuth: util.NewBoolPointer(true),
|
||||
},
|
||||
Server: orgv1.CheClusterSpecServer{
|
||||
ServerExposureStrategy: "single-host",
|
||||
},
|
||||
},
|
||||
}
|
||||
devWorkspaceCSV := &operatorsv1alpha1.ClusterServiceVersion{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: DevWorkspaceCSVName,
|
||||
Namespace: "openshift-operators",
|
||||
},
|
||||
Spec: operatorsv1alpha1.ClusterServiceVersionSpec{},
|
||||
}
|
||||
|
||||
deployContext := deploy.GetTestDeployContext(cheCluster, []runtime.Object{})
|
||||
deployContext.ClusterAPI.Scheme.AddKnownTypes(operatorsv1alpha1.SchemeGroupVersion, &operatorsv1alpha1.ClusterServiceVersion{})
|
||||
deployContext.ClusterAPI.Scheme.AddKnownTypes(operatorsv1alpha1.SchemeGroupVersion, &operatorsv1alpha1.ClusterServiceVersionList{})
|
||||
deployContext.ClusterAPI.Client.Create(context.TODO(), devWorkspaceCSV)
|
||||
deployContext.ClusterAPI.DiscoveryClient.(*fakeDiscovery.FakeDiscovery).Fake.Resources = []*metav1.APIResourceList{
|
||||
{
|
||||
APIResources: []metav1.APIResource{
|
||||
{
|
||||
Name: ClusterServiceVersionResourceName,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
util.IsOpenShift = true
|
||||
util.IsOpenShift4 = true
|
||||
reconciled, _ := ReconcileDevWorkspace(deployContext)
|
||||
|
||||
if !reconciled {
|
||||
t.Fatalf("Failed to reconcile DevWorkspace")
|
||||
}
|
||||
|
||||
// Get Devworkspace namespace. If error is thrown means devworkspace is not anymore installed if CSV is detected
|
||||
err := deployContext.ClusterAPI.Client.Get(context.TODO(), client.ObjectKey{Name: DevWorkspaceNamespace}, &corev1.Namespace{})
|
||||
if err == nil {
|
||||
t.Fatal("Failed to reconcile DevWorkspace when DWO CSV is exptected to be created")
|
||||
}
|
||||
}
|
||||
|
||||
func TestShouldSyncNewObject(t *testing.T) {
|
||||
deployContext := deploy.GetTestDeployContext(nil, []runtime.Object{})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue