From 7f29425884011bcd3cb4cd659312067708d14979 Mon Sep 17 00:00:00 2001 From: Mykola Morhun Date: Fri, 3 Apr 2020 13:52:01 +0300 Subject: [PATCH] Add ability to duplicate some messages at the end of chectl output Signed-off-by: Mykola Morhun --- src/commands/server/start.ts | 26 ++++++++++++++++--- .../component-installers/cert-manager.ts | 6 +++-- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/commands/server/start.ts b/src/commands/server/start.ts index d4641e644..7272a3bde 100644 --- a/src/commands/server/start.ts +++ b/src/commands/server/start.ts @@ -255,6 +255,8 @@ export default class Start extends Command { ctx.directory = path.resolve(flags.directory ? flags.directory : path.resolve(os.tmpdir(), 'chectl-logs', Date.now().toString())) const listrOptions: Listr.ListrOptions = { renderer: (flags['listr-renderer'] as any), collapse: false, showSubtasks: true } as Listr.ListrOptions ctx.listrOptions = listrOptions + // Holds messages which should be printed at the end of chectl log + ctx.highlightedMessages = [] as string[] const cheTasks = new CheTasks(flags) const platformTasks = new PlatformTasks() @@ -281,10 +283,26 @@ export default class Start extends Command { }], listrOptions) // Post Install Checks - const postInstallTasks = new Listr([{ - title: '✅ Post installation checklist', - task: () => new Listr(cheTasks.waitDeployedChe(flags, this)) - }], listrOptions) + const postInstallTasks = new Listr([ + { + title: '✅ Post installation checklist', + task: () => new Listr(cheTasks.waitDeployedChe(flags, this)) + }, + { + title: 'Show important messages', + enabled: ctx => ctx.highlightedMessages.length > 0, + task: (ctx: any) => { + const printMessageTasks = new Listr([], ctx.listrOptions) + for (const message of ctx.highlightedMessages) { + printMessageTasks.add({ + title: message, + task: () => { } + }) + } + return printMessageTasks + } + } + ], listrOptions) const logsTasks = new Listr([{ title: 'Start following logs', diff --git a/src/tasks/component-installers/cert-manager.ts b/src/tasks/component-installers/cert-manager.ts index a0ab7b763..15af85741 100644 --- a/src/tasks/component-installers/cert-manager.ts +++ b/src/tasks/component-installers/cert-manager.ts @@ -162,7 +162,7 @@ export class CertManagerTasks { }, { title: 'Add local Eclipse Che CA certificate into browser', - task: async (_ctx: any, task: any) => { + task: async (ctx: any, task: any) => { const cheSecret = await this.kubeHelper.getSecret(CHE_TLS_SECRET_NAME, flags.chenamespace) if (cheSecret && cheSecret.data) { const cheCaCrt = Buffer.from(cheSecret.data['ca.crt'], 'base64').toString('ascii') @@ -171,7 +171,9 @@ export class CertManagerTasks { const yellow = '\x1b[33m' const noColor = '\x1b[0m' - task.title = `❗${yellow}[MANUAL ACTION REQUIRED]${noColor} Please add local Eclipse Che CA certificate into your browser: ${cheCaPublicCertPath}` + const message = `❗${yellow}[MANUAL ACTION REQUIRED]${noColor} Please add local Eclipse Che CA certificate into your browser: ${cheCaPublicCertPath}` + task.title = message + ctx.highlightedMessages.push(message) } else { throw new Error('Failed to get Cert Manager CA secret') }