diff --git a/src/api/che.ts b/src/api/che.ts index 7fbfb525a..1128a6a03 100644 --- a/src/api/che.ts +++ b/src/api/che.ts @@ -271,38 +271,6 @@ export class CheHelper { return this.kube.namespaceExist(namespace) } - /** - * DEPRECATED. Use CheApiClient instead. - */ - async getCheServerStatus(cheURL: string, responseTimeoutMs = this.defaultCheResponseTimeoutMs): Promise { - const cheApi = CheApiClient.getInstance(cheURL + '/api') - return cheApi.getCheServerStatus(responseTimeoutMs) - } - - /** - * DEPRECATED. Use startCheServerShutdown from CheApiClient instead. - */ - async startShutdown(cheURL: string, accessToken = '', responseTimeoutMs = this.defaultCheResponseTimeoutMs) { - const cheApi = CheApiClient.getInstance(cheURL + '/api') - return cheApi.startCheServerShutdown(accessToken, responseTimeoutMs) - } - - /** - * DEPRECATED. Use waitUntilCheServerReadyToShutdown from CheApiClient instead. - */ - async waitUntilReadyToShutdown(cheURL: string, intervalMs = 500, timeoutMs = 60000) { - const cheApi = CheApiClient.getInstance(cheURL + '/api') - return cheApi.waitUntilCheServerReadyToShutdown(intervalMs, timeoutMs) - } - - /** - * DEPRECATED. Use CheApiClient instead. - */ - async isCheServerReady(cheURL: string, responseTimeoutMs = this.defaultCheResponseTimeoutMs): Promise { - const cheApi = CheApiClient.getInstance(cheURL + '/api') - return cheApi.isCheServerReady(responseTimeoutMs) - } - async createWorkspaceFromDevfile(cheApiEndpoint: string, devfilePath: string, workspaceName?: string, accessToken?: string): Promise { let devfile: string | undefined try { @@ -331,14 +299,6 @@ export class CheHelper { } } - /** - * DEPRECATED. Use CheApiClient instead. - */ - async isAuthenticationEnabled(cheURL: string, responseTimeoutMs = this.defaultCheResponseTimeoutMs): Promise { - const cheApi = CheApiClient.getInstance(cheURL + '/api') - return cheApi.isAuthenticationEnabled(responseTimeoutMs) - } - async buildDashboardURL(ideURL: string): Promise { return ideURL.replace(/\/[^/|.]*\/[^/|.]*$/g, '\/dashboard\/#\/ide$&') } diff --git a/src/tasks/che.ts b/src/tasks/che.ts index 0d60114c1..b8c2ed710 100644 --- a/src/tasks/che.ts +++ b/src/tasks/che.ts @@ -11,6 +11,7 @@ import { Command } from '@oclif/command' import * as Listr from 'listr' import { CheHelper } from '../api/che' +import { CheApiClient } from '../api/che-api-client' import { KubeHelper } from '../api/kube' import { OpenShiftHelper } from '../api/openshift' import { DOC_LINK_OBTAIN_ACCESS_TOKEN, DOC_LINK_OBTAIN_ACCESS_TOKEN_OAUTH } from '../constants' @@ -193,8 +194,9 @@ export class CheTasks { let cheURL = '' try { cheURL = await this.che.cheURL(this.cheNamespace) - const status = await this.che.getCheServerStatus(cheURL) - ctx.isAuthEnabled = await this.che.isAuthenticationEnabled(cheURL) + const cheApi = CheApiClient.getInstance(cheURL + '/api') + const status = await cheApi.getCheServerStatus() + ctx.isAuthEnabled = await cheApi.isAuthenticationEnabled() const auth = ctx.isAuthEnabled ? '(auth enabled)' : '(auth disabled)' task.title = `${task.title}...${status} ${auth}` } catch (error) { @@ -259,9 +261,10 @@ export class CheTasks { task: async (task: any) => { try { const cheURL = await this.che.cheURL(this.cheNamespace) - await this.che.startShutdown(cheURL, this.cheAccessToken) - await this.che.waitUntilReadyToShutdown(cheURL) - task.title = await `${task.title}...done` + const cheApi = CheApiClient.getInstance(cheURL + '/api') + await cheApi.startCheServerShutdown(this.cheAccessToken) + await cheApi.waitUntilCheServerReadyToShutdown() + task.title = `${task.title}...done` } catch (error) { command.error(`E_SHUTDOWN_CHE_SERVER_FAIL - Failed to shutdown Eclipse Che server. ${error.message}`) } @@ -624,7 +627,10 @@ export class CheTasks { return [ { title: 'Eclipse Che status check', - task: async ctx => this.che.isCheServerReady(ctx.cheURL) + task: async ctx => { + const cheApi = CheApiClient.getInstance(ctx.cheURL + '/api') + return cheApi.isCheServerReady() + } } ] } @@ -634,7 +640,8 @@ export class CheTasks { { title: 'Checking authentication', task: async (ctx: any, task: any) => { - ctx.isAuthEnabled = await this.che.isAuthenticationEnabled(ctx.cheURL) + const cheApi = CheApiClient.getInstance(ctx.cheURL + '/api') + ctx.isAuthEnabled = await cheApi.isAuthenticationEnabled() if (ctx.isAuthEnabled && !this.cheAccessToken) { throw new Error('E_AUTH_REQUIRED - Eclipse Che authentication is enabled and an access token is needed to be provided (flag --access-token). ' + `See the documentation how to obtain token: ${DOC_LINK_OBTAIN_ACCESS_TOKEN} and ${DOC_LINK_OBTAIN_ACCESS_TOKEN_OAUTH}.`)