From 7905ed158dcf6292683a220ab89bd3460adb0ee2 Mon Sep 17 00:00:00 2001 From: Anatoliy Bazko Date: Tue, 14 Apr 2020 07:55:13 +0300 Subject: [PATCH] Move cr name to constant Signed-off-by: Anatoliy Bazko --- src/commands/server/update.ts | 4 ++-- src/constants.ts | 1 + src/tasks/installers/operator.ts | 12 ++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/commands/server/update.ts b/src/commands/server/update.ts index 423d3b22e..f4d866ac6 100644 --- a/src/commands/server/update.ts +++ b/src/commands/server/update.ts @@ -18,7 +18,7 @@ import * as path from 'path' import { KubeHelper } from '../../api/kube' import { cheDeployment, cheNamespace, listrRenderer } from '../../common-flags' -import { DEFAULT_CHE_OPERATOR_IMAGE } from '../../constants' +import { CHE_CLUSTER_CR_NAME, DEFAULT_CHE_OPERATOR_IMAGE } from '../../constants' import { CheTasks } from '../../tasks/che' import { InstallerTasks } from '../../tasks/installers/installer' import { ApiTasks } from '../../tasks/platforms/api' @@ -159,7 +159,7 @@ export default class Update extends Command { async setDomainFlag(flags: any): Promise { const kubeHelper = new KubeHelper() - const cheCluster = await kubeHelper.getCheCluster('eclipse-che', flags.chenamespace) + const cheCluster = await kubeHelper.getCheCluster(CHE_CLUSTER_CR_NAME, flags.chenamespace) if (cheCluster && cheCluster.spec.k8s && cheCluster.spec.k8s.ingressDomain) { flags.domain = cheCluster.spec.k8s.ingressDomain } diff --git a/src/constants.ts b/src/constants.ts index 929b18c30..c43f23ba0 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -17,3 +17,4 @@ export const CA_CERT_GENERATION_JOB_IMAGE = 'quay.io/eclipse/che-cert-manager-ca export const CERT_MANAGER_NAMESPACE_NAME = 'cert-manager' export const CHE_TLS_SECRET_NAME = 'che-tls' +export const CHE_CLUSTER_CR_NAME = 'eclipse-che' diff --git a/src/tasks/installers/operator.ts b/src/tasks/installers/operator.ts index cc2349b82..bcf157c78 100644 --- a/src/tasks/installers/operator.ts +++ b/src/tasks/installers/operator.ts @@ -19,6 +19,7 @@ import * as path from 'path' import { CheHelper } from '../../api/che' import { KubeHelper } from '../../api/kube' +import { CHE_CLUSTER_CR_NAME } from '../../constants' import { isKubernetesPlatformFamily } from '../../util' export class OperatorTasks { @@ -29,7 +30,6 @@ export class OperatorTasks { operatorClusterRoleBinding = 'che-operator' cheClusterCrd = 'checlusters.org.eclipse.che' operatorName = 'che-operator' - operatorCheCluster = 'eclipse-che' resourcesPath = '' /** @@ -226,9 +226,9 @@ export class OperatorTasks { } }, { - title: `Create Eclipse Che cluster ${this.operatorCheCluster} in namespace ${flags.chenamespace}`, + title: `Create Eclipse Che cluster ${CHE_CLUSTER_CR_NAME} in namespace ${flags.chenamespace}`, task: async (ctx: any, task: any) => { - const cheCluster = await kube.getCheCluster(this.operatorCheCluster, flags.chenamespace) + const cheCluster = await kube.getCheCluster(CHE_CLUSTER_CR_NAME, flags.chenamespace) if (cheCluster) { task.title = `${task.title}...It already exists.` } else { @@ -427,11 +427,11 @@ export class OperatorTasks { deleteTasks(flags: any): ReadonlyArray { let kh = new KubeHelper(flags) return [{ - title: `Delete the CR ${this.operatorCheCluster} of type ${this.cheClusterCrd}`, + title: `Delete the CR ${CHE_CLUSTER_CR_NAME} of type ${this.cheClusterCrd}`, task: async (_ctx: any, task: any) => { if (await kh.crdExist(this.cheClusterCrd) && - await kh.getCheCluster(this.operatorCheCluster, flags.chenamespace)) { - await kh.deleteCheCluster(this.operatorCheCluster, flags.chenamespace) + await kh.getCheCluster(CHE_CLUSTER_CR_NAME, flags.chenamespace)) { + await kh.deleteCheCluster(CHE_CLUSTER_CR_NAME, flags.chenamespace) await cli.wait(2000) //wait a couple of secs for the finalizers to be executed task.title = await `${task.title}...OK` } else {