Skip to content

Commit

Permalink
Add ability to duplicate some messages at the end of chectl output (#619
Browse files Browse the repository at this point in the history
)

Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
  • Loading branch information
mmorhun committed Apr 3, 2020
1 parent 64acd38 commit f21c09b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
26 changes: 22 additions & 4 deletions src/commands/server/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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',
Expand Down
6 changes: 4 additions & 2 deletions src/tasks/component-installers/cert-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
}
Expand Down

0 comments on commit f21c09b

Please sign in to comment.