From 9bbdce4e5181cf1483b4d54037897bfffe895821 Mon Sep 17 00:00:00 2001 From: Mykola Morhun Date: Mon, 27 Apr 2020 15:02:02 +0300 Subject: [PATCH] Fixes according review Signed-off-by: Mykola Morhun --- src/api/che.ts | 4 ++-- src/commands/cacert/export.ts | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/api/che.ts b/src/api/che.ts index 95fbbde72..db8b3a533 100644 --- a/src/api/che.ts +++ b/src/api/che.ts @@ -114,14 +114,14 @@ export class CheHelper { async retrieveEclipseCheCaCert(cheNamespace: string): Promise { const cheCaSecret = await this.kube.getSecret(CHE_ROOT_CA_SECRET_NAME, cheNamespace) if (!cheCaSecret) { - throw new Error('Local Che CA self-signed certificate not found. Are you using self-signed certificate?') + throw new Error('Che CA self-signed certificate not found. Are you using self-signed certificate?') } if (cheCaSecret.data && cheCaSecret.data['ca.crt']) { return Buffer.from(cheCaSecret.data['ca.crt'], 'base64').toString('ascii') } - throw new Error(`Secret "${CHE_ROOT_CA_SECRET_NAME}" has invalid format.`) + throw new Error(`Secret "${CHE_ROOT_CA_SECRET_NAME}" has invalid format: "ca.crt" key not found in data.`) } async cheK8sURL(namespace = ''): Promise { diff --git a/src/commands/cacert/export.ts b/src/commands/cacert/export.ts index a1f3b0a87..e098e79d7 100644 --- a/src/commands/cacert/export.ts +++ b/src/commands/cacert/export.ts @@ -36,12 +36,12 @@ export default class Export extends Command { }), destination: string({ char: 'd', - description: `Destination where to store Che certificate. + description: `Destination where to store Che CA certificate. If the destination is a file (might not exist), then the certificate will be saved there in PEM format. If the destination is a directory, then ${DEFAULT_CA_CERT_FILE_NAME} file will be created there with Che certificate in PEM format. If this option is ommited, then Che certificate will be stored in user's home directory as ${DEFAULT_CA_CERT_FILE_NAME}`, env: 'CHE_CA_CERT_LOCATION', - default: '~' + default: '' }), } @@ -54,7 +54,7 @@ export default class Export extends Command { const apiTasks = new ApiTasks() const tasks = new Listr([], { renderer: 'silent' }) - const targetFile = this.prepareTarget(flags.destination) + const targetFile = this.getTargetFile(flags.destination) tasks.add(platformTasks.preflightCheckTasks(flags, this)) tasks.add(apiTasks.testApiTasks(flags, this)) @@ -73,8 +73,8 @@ export default class Export extends Command { /** * Handles certificate target location and returns string which points to the target file. */ - private prepareTarget(destinaton: string): string { - if (destinaton === '~') { + private getTargetFile(destinaton: string): string { + if (!destinaton) { return path.join(os.homedir(), DEFAULT_CA_CERT_FILE_NAME) } @@ -82,7 +82,7 @@ export default class Export extends Command { return fs.lstatSync(destinaton).isDirectory() ? path.join(destinaton, DEFAULT_CA_CERT_FILE_NAME) : destinaton } - throw new Error('Given certificate path doesn\'t exist.') + this.error(`Given path "${destinaton}" doesn\'t exist.`) } }