Skip to content

Commit

Permalink
fix(messages): Improve warn messages (#714)
Browse files Browse the repository at this point in the history
* Improve warn messages

Signed-off-by: Anatoliy Bazko <[email protected]>
  • Loading branch information
tolusha authored May 19, 2020
1 parent 7bd5404 commit 5b59b4e
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/commands/server/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { InstallerTasks } from '../../tasks/installers/installer'
import { ApiTasks } from '../../tasks/platforms/api'
import { CommonPlatformTasks } from '../../tasks/platforms/common-platform-tasks'
import { PlatformTasks } from '../../tasks/platforms/platform'
import { isOpenshiftPlatformFamily } from '../../util'
import { isOpenshiftPlatformFamily, isStableVersion } from '../../util'

export default class Start extends Command {
static description = 'start Eclipse Che server'
Expand Down Expand Up @@ -414,9 +414,8 @@ export default class Start extends Command {
* and `operator` for other cases.
*/
async setDefaultInstaller(flags: any): Promise<void> {
const cheVersion = DEFAULT_CHE_OPERATOR_IMAGE.split(':')[1]
const kubeHelper = new KubeHelper(flags)
if (flags.platform === 'openshift' && await kubeHelper.isOpenShift4() && cheVersion !== 'nightly' && cheVersion !== 'latest') {
if (flags.platform === 'openshift' && await kubeHelper.isOpenShift4() && isStableVersion(flags)) {
flags.installer = 'olm'
} else {
flags.installer = 'operator'
Expand Down
6 changes: 4 additions & 2 deletions src/tasks/installers/helm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { KubeHelper } from '../../api/kube'
import { VersionHelper } from '../../api/version'
import { CHE_TLS_SECRET_NAME } from '../../constants'
import { CertManagerTasks } from '../../tasks/component-installers/cert-manager'
import { generatePassword } from '../../util'
import { generatePassword, isStableVersion } from '../../util'

export class HelmTasks {
protected kubeHelper: KubeHelper
Expand All @@ -34,7 +34,9 @@ export class HelmTasks {
* Returns list of tasks which perform preflight platform checks.
*/
startTasks(flags: any, command: Command): Listr {
command.warn('You can also use features rich \'OLM\' installer to deploy Eclipse Che.')
if (isStableVersion(flags)) {
command.warn('Consider using the more reliable \'OLM\' installer when deploying a stable release of Eclipse Che (--installer=olm).')
}
return new Listr([
{
title: 'Verify if helm is installed',
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/installers/olm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class OLMTasks {
startTasks(flags: any, command: Command): Listr {
const kube = new KubeHelper(flags)
if (this.isNightlyChectlChannel() && !flags['catalog-source-yaml']) {
command.warn('OLM catalog hasn\'t got nightly channel, that\'s why will be deployed stable Eclipse Che.')
command.warn('A nightly channel for Eclipse Che is not available on OpenShift OLM catalog, the latest stable release will be deployed instead. To get a nightly release of Eclipse Che use the `operator` installer (--installer=operator).')
}
return new Listr([
this.isOlmPreInstalledTask(command, kube),
Expand Down
5 changes: 4 additions & 1 deletion src/tasks/installers/operator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import * as Listr from 'listr'

import { KubeHelper } from '../../api/kube'
import { CHE_CLUSTER_CR_NAME } from '../../constants'
import { isStableVersion } from '../../util'

import { checkTlsCertificate, copyOperatorResources, createEclipseCheCluster, createNamespaceTask } from './common-tasks'

Expand All @@ -33,7 +34,9 @@ export class OperatorTasks {
*/
startTasks(flags: any, command: Command): Listr {
const kube = new KubeHelper(flags)
command.warn('You can also use features rich \'OLM\' installer to deploy Eclipse Che.')
if (isStableVersion(flags)) {
command.warn('Consider using the more reliable \'OLM\' installer when deploying a stable release of Eclipse Che (--installer=olm).')
}
return new Listr([
copyOperatorResources(flags, command.config.cacheDir),
createNamespaceTask(flags),
Expand Down
11 changes: 11 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

import * as commandExists from 'command-exists'

import { DEFAULT_CHE_OPERATOR_IMAGE } from './constants'

export const KUBERNETES_CLI = 'kubectl'
export const OPENSHIFT_CLI = 'oc'

Expand Down Expand Up @@ -64,3 +66,12 @@ export function generatePassword(passwodLength: number, charactersSet = '') {
export function base64Decode(arg: string): string {
return Buffer.from(arg, 'base64').toString('ascii')
}

/**
* Indicates if stable version of `chectl` is used.
*/
export function isStableVersion(flags: any): boolean {
const operatorImage = flags['che-operator-image'] || DEFAULT_CHE_OPERATOR_IMAGE
const cheVersion = operatorImage.split(':')[1]
return cheVersion !== 'nightly' && cheVersion !== 'latest'
}
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1525,11 +1525,11 @@ ecc-jsbn@~0.1.1:

"eclipse-che-operator@git://github.com/eclipse/che-operator#master":
version "0.0.0"
resolved "git://github.com/eclipse/che-operator#8a4e1d5edfd26f74418c1fca03a590321418d429"
resolved "git://github.com/eclipse/che-operator#e7ed1e5fa647f173f39e49332610bb41836e6056"

"eclipse-che@git://github.com/eclipse/che#master":
version "0.0.0"
resolved "git://github.com/eclipse/che#998c413ab70d20d67b5f0a4462d25b97e6812d7f"
resolved "git://github.com/eclipse/che#fb063a970d0999915f18a8d4a19835a38a4a74b5"

editorconfig@^0.15.0:
version "0.15.3"
Expand Down

0 comments on commit 5b59b4e

Please sign in to comment.