-
Notifications
You must be signed in to change notification settings - Fork 65
/
start.ts
86 lines (76 loc) · 2.63 KB
/
start.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
* 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
*/
import { Command, Flags } from '@oclif/core'
import { ux } from '@oclif/core'
import {CheCtlContext} from '../../context'
import {
K8S_POD_READY_TIMEOUT_FLAG,
LOG_DIRECTORY_FLAG,
CHE_NAMESPACE_FLAG,
CHE_NAMESPACE,
LISTR_RENDERER_FLAG,
LISTR_RENDERER,
TELEMETRY_FLAG,
TELEMETRY,
SKIP_KUBE_HEALTHZ_CHECK_FLAG,
SKIP_KUBE_HEALTHZ_CHECK,
BATCH_FLAG,
BATCH,
LOG_DIRECTORY,
K8S_POD_WAIT_TIMEOUT_FLAG,
K8S_POD_WAIT_TIMEOUT,
K8S_POD_READY_TIMEOUT,
K8S_POD_DOWNLOAD_IMAGE_TIMEOUT_FLAG,
K8S_POD_DOWNLOAD_IMAGE_TIMEOUT,
K8S_POD_ERROR_RECHECK_TIMEOUT_FLAG, K8S_POD_ERROR_RECHECK_TIMEOUT,
} from '../../flags'
import {EclipseChe} from '../../tasks/installers/eclipse-che/eclipse-che'
import {DEFAULT_ANALYTIC_HOOK_NAME} from '../../constants'
import {CommonTasks} from '../../tasks/common-tasks'
import {CheTasks} from '../../tasks/che-tasks'
import {getCommandSuccessMessage, notifyCommandCompletedSuccessfully, wrapCommandError} from '../../utils/command-utils'
import {newListr} from '../../utils/utls'
export default class Start extends Command {
static description = `Start ${EclipseChe.PRODUCT_NAME} server`
static flags = {
help: Flags.help({ char: 'h' }),
[CHE_NAMESPACE_FLAG]: CHE_NAMESPACE,
[LISTR_RENDERER_FLAG]: LISTR_RENDERER,
[TELEMETRY_FLAG]: TELEMETRY,
[SKIP_KUBE_HEALTHZ_CHECK_FLAG]: SKIP_KUBE_HEALTHZ_CHECK,
[BATCH_FLAG]: BATCH,
[K8S_POD_WAIT_TIMEOUT_FLAG]: K8S_POD_WAIT_TIMEOUT,
[K8S_POD_READY_TIMEOUT_FLAG]: K8S_POD_READY_TIMEOUT,
[K8S_POD_DOWNLOAD_IMAGE_TIMEOUT_FLAG]: K8S_POD_DOWNLOAD_IMAGE_TIMEOUT,
[K8S_POD_ERROR_RECHECK_TIMEOUT_FLAG]: K8S_POD_ERROR_RECHECK_TIMEOUT,
[LOG_DIRECTORY_FLAG]: LOG_DIRECTORY,
}
async run() {
const {flags} = await this.parse(Start)
const ctx = await CheCtlContext.initAndGet(flags, this)
await this.config.runHook(DEFAULT_ANALYTIC_HOOK_NAME, {command: Start.id, flags})
const tasks = newListr()
tasks.add(CommonTasks.getTestKubernetesApiTasks())
tasks.add(CheTasks.getServerLogsTasks(true))
tasks.add(CheTasks.getScaleCheUpTasks())
try {
await tasks.run(ctx)
ux.log(getCommandSuccessMessage())
} catch (err: any) {
this.error(wrapCommandError(err))
}
if (!flags[BATCH_FLAG]) {
notifyCommandCompletedSuccessfully()
}
this.exit(0)
}
}