diff --git a/.github/workflows/minikube-chectl-commands-tests.yml b/.github/workflows/minikube-chectl-commands-tests.yml index d81394ff0..d67f36c55 100644 --- a/.github/workflows/minikube-chectl-commands-tests.yml +++ b/.github/workflows/minikube-chectl-commands-tests.yml @@ -53,6 +53,8 @@ jobs: uses: che-incubator/setup-minikube-action@next with: minikube-version: v1.23.2 + - name: Install chectl from the stable channel + run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=stable - name: Install NodeJS uses: actions/setup-node@v2.1.2 with: diff --git a/README.md b/README.md index 037921993..ded0f139e 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Issues are tracked on the main Eclipse Che Repository: https://github.com/eclips * [Installation](#installation) +* [Updating](#updating) * [Usage](#usage) * [Commands](#commands) * [Contributing](#contributing) @@ -53,15 +54,27 @@ $ bash <(curl -sL https://www.eclipse.org/che/chectl/) $ bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next ``` -Assemblies of chectl are available at [https://github.com/che-incubator/chectl/releases](https://github.com/che-incubator/chectl/releases) - Manual install: -1) Download a .tgz file based on your Operating System / Arch +1) Download a .tgz file based on your Operating System / Arch from [https://github.com/che-incubator/chectl/releases](https://github.com/che-incubator/chectl/releases) 2) Unpack the assembly 3) Move `chectl` folder into a folder like `$HOME/chectl` 4) Add alias `alias chectl=$HOME/chectl/bin/run` +# Updating + +1) Download a .tgz file based on your Operating System / Arch from [https://github.com/che-incubator/chectl/releases](https://github.com/che-incubator/chectl/releases) +2) Unpack the assembly into a local repository +```bash +CHECTL_VERSION= +CHECTL_BINARIES= + +CLIENT_DIR=${XDG_DATA_HOME:="$(cd && pwd)/.local/share"}/chectl/client/${CHECTL_VERSION} +mkdir ${CLIENT_DIR} -p +tar -xzf ${CHECTL_BINARIES} -C ${CLIENT_DIR} --strip-components=1 +``` +3) Update `chectl` from the local repository `chectl update --from-local` by prompting the downloaded version + # Usage ```sh-session $ chectl server:start @@ -269,9 +282,6 @@ OPTIONS -t, --templates=templates Path to the templates folder - -v, --version=version - Version to deploy (e.g. 7.15.2). Defaults to the same as chectl. - --[no-]auto-update Auto update approval strategy for installation Eclipse Che. With this strategy will be provided auto-update Eclipse Che without any human interaction. @@ -487,9 +497,6 @@ OPTIONS -n, --chenamespace=chenamespace Eclipse Che Kubernetes namespace. Default to 'eclipse-che' -t, --templates=templates Path to the templates folder - -v, --version=version Version to deploy (e.g. 7.15.2). Defaults to the same as - chectl. - -y, --yes Automatic yes to prompts; assume "yes" as answer to all prompts and run non-interactively diff --git a/src/api/version.ts b/src/api/version.ts index d5212e8c3..640fd3eb8 100644 --- a/src/api/version.ts +++ b/src/api/version.ts @@ -309,8 +309,8 @@ export namespace VersionHelper { /** * Indicates if stable version of Eclipse Che is specified or meant implicitly. */ - export function isDeployingStableVersion(flags: any): boolean { - return Boolean(flags.version) || !ChectlContext.get().isDevVersion + export function isDeployingStableVersion(_flags: any): boolean { + return !ChectlContext.get().isDevVersion } /** diff --git a/src/commands/server/deploy.ts b/src/commands/server/deploy.ts index 45c30fad1..b9bea8ea4 100644 --- a/src/commands/server/deploy.ts +++ b/src/commands/server/deploy.ts @@ -14,19 +14,18 @@ import { Command, flags } from '@oclif/command' import { boolean, string } from '@oclif/parser/lib/flags' import { cli } from 'cli-ux' import * as Listr from 'listr' -import * as semver from 'semver' import { ChectlContext, OIDCContextKeys, OLM } from '../../api/context' import { KubeHelper } from '../../api/kube' import { batch, cheDeployment, cheDeployVersion, cheNamespace, cheOperatorCRPatchYaml, cheOperatorCRYaml, CHE_OPERATOR_CR_PATCH_YAML_KEY, CHE_OPERATOR_CR_YAML_KEY, CHE_TELEMETRY, DEPLOY_VERSION_KEY, k8sPodDownloadImageTimeout, K8SPODDOWNLOADIMAGETIMEOUT_KEY, k8sPodErrorRecheckTimeout, K8SPODERRORRECHECKTIMEOUT_KEY, k8sPodReadyTimeout, K8SPODREADYTIMEOUT_KEY, k8sPodWaitTimeout, K8SPODWAITTIMEOUT_KEY, listrRenderer, logsDirectory, LOG_DIRECTORY_KEY, skipKubeHealthzCheck as skipK8sHealthCheck } from '../../common-flags' -import { DEFAULT_ANALYTIC_HOOK_NAME, DEFAULT_CHE_NAMESPACE, DEFAULT_OLM_SUGGESTED_NAMESPACE, DOCS_LINK_INSTALL_RUNNING_CHE_LOCALLY, DOC_LINK_CONFIGURE_API_SERVER, MIN_CHE_OPERATOR_INSTALLER_VERSION, MIN_OLM_INSTALLER_VERSION } from '../../constants' +import { DEFAULT_ANALYTIC_HOOK_NAME, DEFAULT_CHE_NAMESPACE, DEFAULT_OLM_SUGGESTED_NAMESPACE, DOCS_LINK_INSTALL_RUNNING_CHE_LOCALLY, DOC_LINK_CONFIGURE_API_SERVER } from '../../constants' import { CheTasks } from '../../tasks/che' import { DevWorkspaceTasks } from '../../tasks/component-installers/devfile-workspace-operator-installer' import { DexTasks } from '../../tasks/component-installers/dex' -import { checkChectlAndCheVersionCompatibility, createNamespaceTask, downloadTemplates, getPrintHighlightedMessagesTask, retrieveCheCaCertificateTask } from '../../tasks/installers/common-tasks' +import { createNamespaceTask, getPrintHighlightedMessagesTask, retrieveCheCaCertificateTask } from '../../tasks/installers/common-tasks' import { InstallerTasks } from '../../tasks/installers/installer' import { ApiTasks } from '../../tasks/platforms/api' import { PlatformTasks } from '../../tasks/platforms/platform' -import { askForChectlUpdateIfNeeded, getCommandSuccessMessage, getEmbeddedTemplatesDirectory, getProjectName, getTlsSupport, isDevWorkspaceEnabled, isKubernetesPlatformFamily, isOpenshiftPlatformFamily, notifyCommandCompletedSuccessfully, wrapCommandError } from '../../util' +import { askForChectlUpdateIfNeeded, getCommandSuccessMessage, getEmbeddedTemplatesDirectory, getTlsSupport, getWarnVersionFlagMsg, isDevWorkspaceEnabled, isKubernetesPlatformFamily, isOpenshiftPlatformFamily, notifyCommandCompletedSuccessfully, wrapCommandError } from '../../util' export default class Deploy extends Command { static description = 'Deploy Eclipse Che server' @@ -218,11 +217,7 @@ export default class Deploy extends Command { cli.info(` ❕olm-suggested-namespace flag is turned on. Eclipse Che will be deployed in namespace: ${DEFAULT_OLM_SUGGESTED_NAMESPACE}.`) } - if (!ctx.isChectl && flags.version) { - // Flavors of chectl should not use upstream repositories, so version flag is not applicable - this.error(`${getProjectName()} does not support '--version' flag.`) - } - if (!flags.templates && !flags.version) { + if (!flags.templates) { // Use build-in templates if no custom templates nor version to deploy specified. // All flavors should use embedded templates if not custom templates is given. flags.templates = getEmbeddedTemplatesDirectory() @@ -263,14 +258,6 @@ export default class Deploy extends Command { if (flags[OLM.CATALOG_SOURCE_NAME] && flags[OLM.CATALOG_SOURCE_YAML]) { this.error(`should be provided only one argument: "${OLM.CATALOG_SOURCE_NAME}" or "${OLM.CATALOG_SOURCE_YAML}"`) } - if (flags.version) { - if (flags[OLM.STARTING_CSV]) { - this.error(`"${OLM.STARTING_CSV}" and "version" flags are mutually exclusive. Please specify only one of them.`) - } - if (flags[OLM.AUTO_UPDATE]) { - this.error(`enabled "${OLM.AUTO_UPDATE}" flag cannot be used with version flag. Deploy latest version instead.`) - } - } if (!flags[OLM.PACKAGE_MANIFEST_NAME] && flags[OLM.CATALOG_SOURCE_YAML]) { this.error(`you need to define "${OLM.PACKAGE_MANIFEST_NAME}" flag to use "${OLM.CATALOG_SOURCE_YAML}".`) @@ -302,34 +289,6 @@ export default class Deploy extends Command { this.error('"cluster-monitoring" flag should be used only with "olm" installer and "openshift" platform.') } } - - if (flags.version) { - // Check minimal allowed version to install - let minAllowedVersion: string - switch (flags.installer) { - case 'olm': - minAllowedVersion = MIN_OLM_INSTALLER_VERSION - break - case 'operator': - minAllowedVersion = MIN_CHE_OPERATOR_INSTALLER_VERSION - break - default: - // Should never happen - minAllowedVersion = 'latest' - } - - let isVersionAllowed = false - try { - isVersionAllowed = semver.gte(flags.version, minAllowedVersion) - } catch (error) { - // not to fail unexpectedly - cli.debug(`Failed to compare versions '${flags.version}' and '${minAllowedVersion}': ${error}`) - } - - if (!isVersionAllowed) { - throw new Error(`This chectl version can deploy version ${minAllowedVersion} and higher. If you need to deploy ${flags.version} or lower, download the corresponding legacy chectl version.`) - } - } } async run() { @@ -341,6 +300,11 @@ export default class Deploy extends Command { await askForChectlUpdateIfNeeded() } + if (flags.version) { + cli.info(getWarnVersionFlagMsg(flags)) + this.exit(1) + } + await this.setPlaformDefaults(flags, ctx) await this.config.runHook(DEFAULT_ANALYTIC_HOOK_NAME, { command: Deploy.id, flags }) @@ -362,8 +326,6 @@ export default class Deploy extends Command { task: () => new Listr(cheTasks.checkIfCheIsInstalledTasks(flags)), }) preInstallTasks.add(ensureOIDCProviderInstalled(flags)) - preInstallTasks.add(checkChectlAndCheVersionCompatibility(flags)) - preInstallTasks.add(downloadTemplates(flags)) preInstallTasks.add({ title: '🧪 DevWorkspace engine', enabled: () => isDevWorkspaceEnabled(ctx) && !ctx.isOpenShift, diff --git a/src/commands/server/update.ts b/src/commands/server/update.ts index 6f7ddeb98..3892f1d77 100644 --- a/src/commands/server/update.ts +++ b/src/commands/server/update.ts @@ -21,11 +21,11 @@ import { CheHelper } from '../../api/che' import { ChectlContext } from '../../api/context' import { KubeHelper } from '../../api/kube' import { assumeYes, batch, cheDeployment, cheDeployVersion, cheNamespace, cheOperatorCRPatchYaml, CHE_OPERATOR_CR_PATCH_YAML_KEY, CHE_TELEMETRY, DEPLOY_VERSION_KEY, listrRenderer, skipKubeHealthzCheck } from '../../common-flags' -import { DEFAULT_ANALYTIC_HOOK_NAME, DEFAULT_CHE_OPERATOR_IMAGE_NAME, MIN_CHE_OPERATOR_INSTALLER_VERSION, NEXT_TAG } from '../../constants' -import { checkChectlAndCheVersionCompatibility, downloadTemplates, getPrintHighlightedMessagesTask } from '../../tasks/installers/common-tasks' +import { DEFAULT_ANALYTIC_HOOK_NAME, DEFAULT_CHE_OPERATOR_IMAGE_NAME, NEXT_TAG } from '../../constants' +import { getPrintHighlightedMessagesTask } from '../../tasks/installers/common-tasks' import { InstallerTasks } from '../../tasks/installers/installer' import { ApiTasks } from '../../tasks/platforms/api' -import { askForChectlUpdateIfNeeded, findWorkingNamespace, getCommandSuccessMessage, getEmbeddedTemplatesDirectory, getProjectName, getProjectVersion, notifyCommandCompletedSuccessfully, wrapCommandError } from '../../util' +import { askForChectlUpdateIfNeeded, findWorkingNamespace, getCommandSuccessMessage, getEmbeddedTemplatesDirectory, getProjectName, getProjectVersion, getWarnVersionFlagMsg, notifyCommandCompletedSuccessfully, wrapCommandError } from '../../util' export default class Update extends Command { static description = 'Update Eclipse Che server.' @@ -88,6 +88,11 @@ export default class Update extends Command { await askForChectlUpdateIfNeeded() } + if (flags.version) { + cli.info(getWarnVersionFlagMsg(flags)) + this.exit(1) + } + await this.setDomainFlag(flags) if (!flags.installer) { await this.setDefaultInstaller(flags) @@ -96,42 +101,18 @@ export default class Update extends Command { await this.config.runHook(DEFAULT_ANALYTIC_HOOK_NAME, { command: Update.id, flags }) - if (!flags.templates && !flags.version) { + if (!flags.templates) { // Use build-in templates if no custom templates nor version to deploy specified. // All flavors should use embedded templates if not custom templates is given. flags.templates = getEmbeddedTemplatesDirectory() } - if (flags.version) { - if (!ctx.isChectl) { - // Flavors of chectl should not use upstream repositories, so version flag is not appliable - this.error(`${getProjectName()} does not support '--version' flag.`) - } - if (flags.installer === 'olm') { - this.error(`'--${DEPLOY_VERSION_KEY}' flag is not supported for OLM installer. 'server:update' command automatically updates to the next available version.`) - } - - let isVersionAllowed = false - try { - isVersionAllowed = semver.gte(flags.version, MIN_CHE_OPERATOR_INSTALLER_VERSION) - } catch (error) { - // not to fail unexpectedly - cli.debug(`Failed to compare versions '${flags.version}' and '${MIN_CHE_OPERATOR_INSTALLER_VERSION}': ${error}`) - } - - if (flags.installer === 'operator' && !isVersionAllowed) { - throw new Error(this.getWrongVersionMessage(flags.version, MIN_CHE_OPERATOR_INSTALLER_VERSION)) - } - } - const installerTasks = new InstallerTasks() // pre update tasks const apiTasks = new ApiTasks() const preUpdateTasks = new Listr([], ctx.listrOptions) preUpdateTasks.add(apiTasks.testApiTasks(flags)) - preUpdateTasks.add(checkChectlAndCheVersionCompatibility(flags)) - preUpdateTasks.add(downloadTemplates(flags)) preUpdateTasks.add(installerTasks.preUpdateTasks(flags, this)) // update tasks @@ -372,8 +353,4 @@ export default class Update extends Command { flags.installer = 'operator' } } - - private getWrongVersionMessage(current: string, minimal: string): string { - return `This chectl version can deploy ${minimal} version and higher, but ${current} is provided. If you really need to deploy that old version, please download corresponding legacy chectl version.` - } } diff --git a/src/common-flags.ts b/src/common-flags.ts index 0c8c5cf00..7eaccc42d 100644 --- a/src/common-flags.ts +++ b/src/common-flags.ts @@ -126,6 +126,7 @@ export const cheDeployVersion = string({ char: 'v', description: 'Version to deploy (e.g. 7.15.2). Defaults to the same as chectl.', env: 'CHE_DEPLOY_VERSION', + hidden: true, }) export const FOLLOW_LOGS = boolean({ diff --git a/src/tasks/installers/common-tasks.ts b/src/tasks/installers/common-tasks.ts index 93831283a..e6ca7c9ad 100644 --- a/src/tasks/installers/common-tasks.ts +++ b/src/tasks/installers/common-tasks.ts @@ -17,15 +17,11 @@ import * as os from 'os' import * as Listr from 'listr' import { isEmpty } from 'lodash' import * as path from 'path' -import * as semver from 'semver' import { CheHelper } from '../../api/che' import { ChectlContext } from '../../api/context' -import { CheGithubClient } from '../../api/github-client' import { KubeHelper } from '../../api/kube' -import { VersionHelper } from '../../api/version' -import { CHE_CLUSTER_CRD, DEFAULT_CA_CERT_FILE_NAME, DOCS_LINK_IMPORT_CA_CERT_INTO_BROWSER, OPERATOR_TEMPLATE_DIR } from '../../constants' -import { getProjectVersion } from '../../util' +import { CHE_CLUSTER_CRD, DEFAULT_CA_CERT_FILE_NAME, DOCS_LINK_IMPORT_CA_CERT_INTO_BROWSER } from '../../constants' export const TASK_TITLE_CREATE_CHE_CLUSTER_CRD = `Create the Custom Resource of type ${CHE_CLUSTER_CRD}` export const TASK_TITLE_PATCH_CHECLUSTER_CR = `Patching the Custom Resource of type ${CHE_CLUSTER_CRD}` @@ -49,72 +45,6 @@ export function createNamespaceTask(namespaceName: string, labels: {}): Listr.Li } } -export function checkChectlAndCheVersionCompatibility(flags: any): Listr.ListrTask { - return { - title: 'Check versions compatibility', - enabled: ctx => ctx.isChectl && !flags.templates && flags.version && flags.installer !== 'olm', - task: async (ctx: any, task: any) => { - const githubClient = new CheGithubClient() - const verInfo = await githubClient.getTemplatesTagInfo(flags.installer, flags.version) - if (!verInfo) { - throw new Error(`Version ${flags.version} does not exist`) - } - ctx.versionInfo = verInfo - flags.version = VersionHelper.removeVPrefix(verInfo.name, true) - - if (!ctx.isDevVersion && semver.lt(getProjectVersion(), flags.version)) { - throw new Error(`To deploy Eclipse Che ${flags.version}, please update your chectl first by running "chectl update".`) - } - - task.title = `${task.title}... OK` - }, - } -} - -/** - * Sets flags.templates based on required version and installer. - * Does not support OLM. - */ -export function downloadTemplates(flags: any): Listr.ListrTask { - return { - title: 'Download templates', - enabled: ctx => ctx.isChectl && flags.version && !flags.templates && flags.installer !== 'olm', - task: async (ctx: any, task: any) => { - // All templates are stored in the cache directory - // Example path: ~/.cache/chectl/templates/7.15.1/ - const templatesRootDir = path.join(ctx[ChectlContext.CACHE_DIR], 'templates') - - let installerTemplatesSubDir: string - switch (flags.installer) { - case 'operator': - installerTemplatesSubDir = OPERATOR_TEMPLATE_DIR - break - case 'olm': - // Should be handled on install phase when catalog source is deployed - return - default: - throw new Error(`Unknow installer ${flags.installer}`) - } - - const versionTemplatesDirPath = path.join(templatesRootDir, flags.version) - flags.templates = versionTemplatesDirPath - - const installerTemplatesDirPath = path.join(versionTemplatesDirPath, installerTemplatesSubDir) - if (await fs.pathExists(installerTemplatesDirPath)) { - // Use cached templates - task.title = `${task.title}... found cached templates for version ${flags.version}` - return - } - - // Download templates - task.title = `${task.title} for version ${flags.version}` - const cheHelper = new CheHelper(flags) - await cheHelper.downloadAndUnpackTemplates(flags.installer, ctx.versionInfo.zipball_url, versionTemplatesDirPath) - task.title = `${task.title} ... OK` - }, - } -} - export function createEclipseCheCluster(flags: any, kube: KubeHelper): Listr.ListrTask { return { title: TASK_TITLE_CREATE_CHE_CLUSTER_CRD, diff --git a/src/tasks/installers/olm.ts b/src/tasks/installers/olm.ts index 023707fbf..2bca44a68 100644 --- a/src/tasks/installers/olm.ts +++ b/src/tasks/installers/olm.ts @@ -19,7 +19,7 @@ import { OLM, OLMInstallationUpdate } from '../../api/context' import { KubeHelper } from '../../api/kube' import { CatalogSource, Subscription } from '../../api/types/olm' import { VersionHelper } from '../../api/version' -import { CHECTL_PROJECT_NAME, CSV_PREFIX, CUSTOM_CATALOG_SOURCE_NAME, DEFAULT_CHE_NAMESPACE, DEFAULT_CHE_OLM_PACKAGE_NAME, DEFAULT_CHE_OPERATOR_SUBSCRIPTION_NAME, DEFAULT_OLM_KUBERNETES_NAMESPACE, DEFAULT_OPENSHIFT_MARKET_PLACE_NAMESPACE, DEFAULT_OPENSHIFT_OPERATORS_NS_NAME, INDEX_IMG, KUBERNETES_OLM_CATALOG, NEXT_CATALOG_SOURCE_NAME, OLM_NEXT_CHANNEL_NAME, OLM_STABLE_CHANNEL_NAME, OLM_STABLE_CHANNEL_STARTING_CSV_TEMPLATE, OPENSHIFT_OLM_CATALOG, OPERATOR_GROUP_NAME } from '../../constants' +import { CHECTL_PROJECT_NAME, CSV_PREFIX, CUSTOM_CATALOG_SOURCE_NAME, DEFAULT_CHE_NAMESPACE, DEFAULT_CHE_OLM_PACKAGE_NAME, DEFAULT_CHE_OPERATOR_SUBSCRIPTION_NAME, DEFAULT_OLM_KUBERNETES_NAMESPACE, DEFAULT_OPENSHIFT_MARKET_PLACE_NAMESPACE, DEFAULT_OPENSHIFT_OPERATORS_NS_NAME, INDEX_IMG, KUBERNETES_OLM_CATALOG, NEXT_CATALOG_SOURCE_NAME, OLM_NEXT_CHANNEL_NAME, OLM_STABLE_CHANNEL_NAME, OPENSHIFT_OLM_CATALOG, OPERATOR_GROUP_NAME } from '../../constants' import { getEmbeddedTemplatesDirectory, getProjectName, isKubernetesPlatformFamily } from '../../util' import { createEclipseCheCluster, patchingEclipseCheCluster } from './common-tasks' import { OLMDevWorkspaceTasks } from './olm-dev-workspace-operator' @@ -60,27 +60,14 @@ export class OLMTasks { ctx.sourceName = flags[OLM.CATALOG_SOURCE_NAME] || CUSTOM_CATALOG_SOURCE_NAME ctx.generalPlatformName = isKubernetesPlatformFamily(flags.platform) ? 'kubernetes' : 'openshift' - if (flags.version) { - // Convert version flag to channel (see subscription object), starting CSV and approval starategy - flags.version = VersionHelper.removeVPrefix(flags.version, true) - // Need to point to specific CSV - if (flags[OLM.STARTING_CSV]) { - ctx.startingCSV = flags[OLM.STARTING_CSV] - } else if (flags[OLM.CHANNEL] === OLM_STABLE_CHANNEL_NAME) { - ctx.startingCSV = OLM_STABLE_CHANNEL_STARTING_CSV_TEMPLATE.replace(new RegExp('{{VERSION}}', 'g'), flags.version) - } // else use latest in the channel - // Set approval starategy to manual to prevent autoupdate to the latest version right before installation + ctx.startingCSV = flags[OLM.STARTING_CSV] + if (ctx.startingCSV) { + // Ignore auto-update flag, otherwise it will automatically update to the latest version and 'starting-csv' will not have any effect. ctx.approvalStrategy = OLMInstallationUpdate.MANUAL + } else if (flags[OLM.AUTO_UPDATE] === undefined) { + ctx.approvalStrategy = OLMInstallationUpdate.AUTO } else { - ctx.startingCSV = flags[OLM.STARTING_CSV] - if (ctx.startingCSV) { - // Ignore auto-update flag, otherwise it will automatically update to the latest version and 'starting-csv' will not have any effect. - ctx.approvalStrategy = OLMInstallationUpdate.MANUAL - } else if (flags[OLM.AUTO_UPDATE] === undefined) { - ctx.approvalStrategy = OLMInstallationUpdate.AUTO - } else { - ctx.approvalStrategy = flags[OLM.AUTO_UPDATE] ? OLMInstallationUpdate.AUTO : OLMInstallationUpdate.MANUAL - } + ctx.approvalStrategy = flags[OLM.AUTO_UPDATE] ? OLMInstallationUpdate.AUTO : OLMInstallationUpdate.MANUAL } task.title = `${task.title}...[OK]` diff --git a/src/util.ts b/src/util.ts index 333fe1379..5109fe6e8 100644 --- a/src/util.ts +++ b/src/util.ts @@ -432,3 +432,9 @@ export function getTlsSecretName(ctx: any): string { return DEFAULT_CHE_TLS_SECRET_NAME } + +export function getWarnVersionFlagMsg(_flags: any): string { + return `'--version' flag is not supported anymore. +1. Update chectl to a specific version following the doc https://github.com/che-incubator/chectl#updating +2. Use chectl of the specific version to deploy or to upgrade Eclipse Che` +} diff --git a/test/e2e/e2e-upgrade.test.ts b/test/e2e/e2e-upgrade.test.ts index 0f3dc32a7..40c54236b 100644 --- a/test/e2e/e2e-upgrade.test.ts +++ b/test/e2e/e2e-upgrade.test.ts @@ -16,32 +16,25 @@ import { E2eHelper, NAMESPACE } from './util' const helper = new E2eHelper() jest.setTimeout(1000000) -const binChectl = E2eHelper.getChectlBinaries() - const PLATFORM = process.env.PLATFORM || 'minikube' - const INSTALLER = 'operator' const UPDATE_CHE_TIMEOUT_MS = 10 * 60 * 1000 const CHE_VERSION_TIMEOUT_MS = 10 * 60 * 1000 describe('Test Che upgrade', () => { - let cheVersion: string - describe('Prepare latest stable Che', () => { it(`Deploy Che using ${INSTALLER} installer and self signed certificates`, async () => { - // Retrieve latest stable Che version - cheVersion = await helper.getLatestReleasedVersion() - - const deployCommand = `${binChectl} server:deploy --batch --platform=${PLATFORM} --installer=${INSTALLER} --version=${cheVersion} --chenamespace=${NAMESPACE} --telemetry=off` + // uses installed chectl (from a stable channel) + // see github workflow + const deployCommand = `chectl server:deploy --batch --platform=${PLATFORM} --installer=${INSTALLER} --chenamespace=${NAMESPACE} --telemetry=off` await helper.runCliCommand(deployCommand) - - await helper.waitForVersionInCheCR(cheVersion, CHE_VERSION_TIMEOUT_MS) }) }) describe('Test Che update', () => { it('Update Eclipse Che Version', async () => { + const binChectl = E2eHelper.getChectlBinaries() await helper.runCliCommand(binChectl, ['server:update', '-y', `-n ${NAMESPACE}`, '--telemetry=off']) await helper.waitForCheServerImageTag(helper.getNewVersion(), UPDATE_CHE_TIMEOUT_MS) }) diff --git a/test/e2e/e2e.test.ts b/test/e2e/e2e.test.ts index fb07cb7b0..b53ef898d 100644 --- a/test/e2e/e2e.test.ts +++ b/test/e2e/e2e.test.ts @@ -17,7 +17,6 @@ import * as execa from 'execa' import { DEFAULT_OLM_SUGGESTED_NAMESPACE } from '../../src/constants' import { E2eHelper } from './util' -const helper = new E2eHelper() jest.setTimeout(1000000) const binChectl = E2eHelper.getChectlBinaries() @@ -28,14 +27,7 @@ const PLATFORM = process.env.PLATFORM || '' const INSTALLER = process.env.INSTALLER || '' function getDeployCommand(): string { - let command = `${binChectl} server:deploy --batch --platform=${PLATFORM} --installer=${INSTALLER} --chenamespace=${NAMESPACE} --telemetry=off` - - const cheVersion = helper.getNewVersion() - if (cheVersion != 'next') { - command = command + ` --version=${cheVersion}` - } - - return command + return `${binChectl} server:deploy --batch --platform=${PLATFORM} --installer=${INSTALLER} --chenamespace=${NAMESPACE} --telemetry=off` } describe(`server:deploy using ${INSTALLER} installer`, () => { diff --git a/test/e2e/util.ts b/test/e2e/util.ts index 1c5470f7c..ec29b4f50 100644 --- a/test/e2e/util.ts +++ b/test/e2e/util.ts @@ -14,23 +14,11 @@ import { Octokit } from '@octokit/rest' import * as execa from 'execa' import { spawn } from 'child_process' import * as fs from 'fs-extra' -import * as semver from 'semver' import { CheHelper } from '../../src/api/che' import { CheGithubClient, TagInfo } from '../../src/api/github-client' import { KubeHelper } from '../../src/api/kube' import { OpenShiftHelper } from '../../src/api/openshift' -import { DEFAULT_OLM_SUGGESTED_NAMESPACE } from '../../src/constants' - -// Fields which chectl returns for workspace:list commands -interface WorkspaceInfo { - id: string - name: string - namespace: string - status: string -} - -export const DEVFILE_URL = 'https://raw.githubusercontent.com/eclipse-che/che-devfile-registry/master/devfiles/go/devfile.yaml' export const NAMESPACE = 'eclipse-che' export const CHECTL_REPONAME = 'chectl' @@ -127,71 +115,6 @@ export class E2eHelper { }) } - // Return an array with all user workspaces - // async getAllWorkspaces(isOpenshiftPlatformFamily: string): Promise { - private async getAllWorkspaces(): Promise { - const workspaces: WorkspaceInfo[] = [] - const { stdout } = await execa(E2eHelper.getChectlBinaries(), ['workspace:list', `--chenamespace=${DEFAULT_OLM_SUGGESTED_NAMESPACE}`, '--telemetry=off'], { shell: true }) - const regEx = new RegExp('[A-Za-z0-9_-]+', 'g') - for (const line of stdout.split('\n')) { - const items = line.match(regEx) - if (items && items.length > 0 && !items[0].startsWith('Id') && !items[0].startsWith('Current')) { - workspaces.push({ - id: items[0], - name: items[1], - namespace: items[2], - status: items[3], - }) - } - } - return workspaces - } - - // Return id of test workspaces(e2e-tests. Please look devfile-example.yaml file) - async getWorkspaceId(): Promise { - const workspaces = await this.getAllWorkspaces() - if (workspaces.length === 0) { - throw Error('Workspace not found') - } - - const workspaceId = workspaces[0].id - if (!workspaceId) { - throw Error('Error getting workspaceId') - } - - return workspaceId - } - - // Return the status of test workspaces(e2e-tests. Please look devfile-example.yaml file) - async getWorkspaceStatus(): Promise { - const workspaces = await this.getAllWorkspaces() - if (workspaces.length === 0) { - throw Error('Workspace not found') - } - - const workspaceStatus = workspaces[0].status - if (!workspaceStatus) { - throw Error('Error getting workspace status') - } - - return workspaceStatus - } - - async waitWorkspaceStatus(status: string, timeoutMs: number): Promise { - const delayMs = 1000 * 5 - - let totalTimeMs = 0 - while (totalTimeMs < timeoutMs) { - if (await this.getWorkspaceStatus() === status) { - return true - } - await this.sleep(delayMs) - totalTimeMs += delayMs - } - - return false - } - //Return a route from Openshift adding protocol async OCHostname(ingressName: string, namespace: string): Promise { if (await this.oc.routeExist(ingressName, namespace)) { @@ -265,43 +188,6 @@ export class E2eHelper { return tags } - /** - * Returns list of sorted CSVs in stable OLM channel of Che Operator published in community-operators repository. - * The CSVs are sorted from the latest to oldest. - */ - private async listOLMReleasedCSV(): Promise { - const response = await this.octokit.repos.getContent({ - owner: 'redhat-openshift-ecosystem', - repo: 'community-operators-prod', - path: 'operators/eclipse-che', - }) - // There is an array in the response as given path points to a directory - const data = response.data as {name: string}[] - const csvsNames: string[] = [] - data.map(item => csvsNames.push(item.name)) - const stableChannelCSVNames = csvsNames.filter(csvName => { - // Filter versions like 7.37.2-all-namespaces - if (csvName.indexOf('-') !== -1) { - return false - } - - // Filter non x.y.z - const versionParts = csvName.split('.') - if (versionParts.length !== 3) { - return false - } - // Ensure each part is a number - for (const versionPart of versionParts) { - if (!versionPart.match(/^[0-9]+$/)) { - return false - } - } - return true - }) - - return stableChannelCSVNames.sort((verA: string, verB: string) => semver.lt(verA, verB) ? 1 : -1) - } - /** * Get previous version from chectl repository */ @@ -311,25 +197,6 @@ export class E2eHelper { return latestTag.name } - /** - * Gets pre-latest and latest released version from chectl repository - */ - async getTwoLatestReleasedVersions(installer: string): Promise<[string, string]> { - if (installer === 'olm') { - // OLM installer uses community-operators marketplace. - // To list available versions see the following folder: - // https://github.com/redhat-openshift-ecosystem/community-operators-prod/tree/main/operators/eclipse-che - const csvs = await this.listOLMReleasedCSV() - return [csvs[1], csvs[0]] - } else if (installer === 'operator') { - // Operator installer uses templates from GitHub releases, which are marked with tags - const githubClient = new CheGithubClient() - const latestTags = (githubClient as any).sortSemanticTags(await this.listLatestTags(CHECTL_REPONAME)) - return [latestTags[1].name, latestTags[0].name] - } - throw new Error(`Failed to get latest versions: unknown installer '${installer}'`) - } - /** * Check if VERSION file exists and return content. In case if Version file doesn't exists * We are not in release branch and return `next` diff --git a/yarn.lock b/yarn.lock index 8187d542b..4b692020f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2496,7 +2496,7 @@ ecc-jsbn@~0.1.1: "eclipse-che-operator@https://github.com/eclipse-che/che-operator#main": version "0.0.0" - resolved "https://github.com/eclipse-che/che-operator#03f83de7a3e7737e4224a8fe4d722b87c1de4351" + resolved "https://github.com/eclipse-che/che-operator#f451dad61ca463834fad4372763055b440357178" editorconfig@^0.15.0: version "0.15.3"