-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcli.js
More file actions
43 lines (38 loc) · 1.36 KB
/
cli.js
File metadata and controls
43 lines (38 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const program = require('commander')
const configCreator = require('./lib/config-creator.js')
program
.version('v1.0.0')
.option('-c, --containerId <string>', 'containerId generate kubernetes configs for')
.option('-o, --outpath <path>', 'directory to place kubernetes config files')
.option('-m, --remove-mounts <regex>', 'if source mount matches this regex, then it is ignored')
.option('-i, --use-image-as-name', 'use image name as default name')
.option('-r, --root-path <string>', 'root path for volumes. (useful when run in a container)')
.option('-a, --all', 'get config for all containers on host')
.parse(process.argv)
if (!program.containerId && !program.all) {
console.error('katastrophe! missing --containerId or --all')
process.exit(1)
}
if (!program.outpath) {
console.error('katastrophe! missing --outpath')
process.exit(1)
}
if (program.all) {
configCreator.fromContainers(program.outpath, {
removeMounts: program.removeMounts,
useImageAsName: program.useImageAsName,
rootPath: program.rootPath
})
.catch((err) => {
console.error('katastrophe!', err)
})
} else {
configCreator.fromContainer(program.containerId, program.outpath, {
removeMounts: program.removeMounts,
useImageAsName: program.useImageAsName,
rootPath: program.rootPath
})
.catch((err) => {
console.error('katastrophe!', err)
})
}