Skip to content

Commit

Permalink
Fixes according review
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 27, 2020
1 parent c1083d2 commit 4ecd108
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/api/che.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class CheHelper {
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<string> {
Expand Down
10 changes: 5 additions & 5 deletions src/commands/cacert/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class Export extends Command {
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: ''
}),
}

Expand All @@ -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))
Expand All @@ -73,16 +73,16 @@ 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)
}

if (fs.existsSync(destinaton)) {
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.`)
}

}

0 comments on commit 4ecd108

Please sign in to comment.