preload: Fix parsing of --add-certificate option, amend help for --app

Connects-to: #2063
Change-type: patch
This commit is contained in:
Paulo Castro 2020-10-20 22:05:51 +01:00
parent 4373ba7a5d
commit c245dc70c2
2 changed files with 5 additions and 11 deletions

View File

@ -2072,7 +2072,7 @@ the image file path
#### -a, --app APP
name, slug or numeric ID of the application to preload
name of the application to preload
#### -c, --commit COMMIT

View File

@ -43,7 +43,7 @@ interface FlagsDef extends DockerConnectionCliFlags {
'splash-image'?: string;
'dont-check-arch': boolean;
'pin-device-to-release': boolean;
'add-certificate'?: string;
'add-certificate'?: string[];
help: void;
}
@ -84,7 +84,7 @@ export default class PreloadCmd extends Command {
public static flags: flags.Input<FlagsDef> = {
app: flags.string({
description: 'name, slug or numeric ID of the application to preload',
description: 'name of the application to preload',
char: 'a',
}),
commit: flags.string({
@ -115,6 +115,7 @@ The file name must end with '.crt' and must not be already contained in the prel
/etc/ssl/certs folder.
Can be repeated to add multiple certificates.\
`,
multiple: true,
}),
...dockerConnectionCliFlags,
// Redefining --dockerPort here (defined already in dockerConnectionCliFlags)
@ -201,14 +202,7 @@ Can be repeated to add multiple certificates.\
);
}
let certificates: string[];
if (Array.isArray(options['add-certificate'])) {
certificates = options['add-certificate'];
} else if (options['add-certificate'] === undefined) {
certificates = [];
} else {
certificates = [options['add-certificate']];
}
const certificates: string[] = options['add-certificate'] || [];
for (const certificate of certificates) {
if (!certificate.endsWith('.crt')) {
throw new ExpectedError('Certificate file name must end with ".crt"');