-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhkubectl.js
executable file
·95 lines (90 loc) · 2.96 KB
/
hkubectl.js
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
require('./polyfills');
const yargs = require('yargs');
const chalk = require('chalk');
const { readConfig } = require('./helpers/config');
const { config } = require('./builders/config');
const { exec } = require('./builders/exec');
const { exportAll } = require('./builders/export');
const { exportAlgorithms } = require('./builders/exportAlgorithms');
const { exportPipelines } = require('./builders/exportPipelines');
const { importAll } = require('./builders/import');
const { importAlgorithms } = require('./builders/importAlgorithms');
const { importPipelines } = require('./builders/importPipelines');
const algorithms = require('./builders/algorithm');
const pipelines = require('./builders/pipeline');
const dryRun = require('./builders/dry-run');
const sync = require('./builders/sync');
const { dataSource } = require('./builders/dataSource');
const { setupClient } = require('./helpers/clients');
const syncthing = require('./helpers/syncthing/syncthing.js');
global.args = {};
const handleSignals = () => {
process.on('SIGINT', async () => {
await syncthing.remove();
process.exit(0);
});
};
const main = async () => {
handleSignals();
const configFile = await readConfig();
yargs.config(configFile);
yargs.command(exec);
yargs.command(exportAll);
yargs.command(exportAlgorithms);
yargs.command(exportPipelines);
yargs.command(importAll);
yargs.command(importAlgorithms);
yargs.command(importPipelines);
yargs.command(algorithms);
yargs.command(pipelines);
yargs.command(dryRun);
yargs.command(sync);
yargs.command(config);
yargs.command(dataSource);
yargs.options('rejectUnauthorized', {
description: 'set to false to ignore certificate signing errors. Useful for self signed TLS certificate',
type: 'boolean'
});
yargs.options('endpoint', {
description: 'url of hkube api endpoint',
type: 'string'
});
yargs.options('pathPrefix', {
description: 'path prefix url of hkube api endpoint',
type: 'string',
default: '/hkube/api-server/'
});
yargs.options('dataSourcePathPrefix', {
description: 'path prefix url of hkube api endpoint',
type: 'string',
default: '/hkube/datasources-service/'
});
yargs.options('verbose', {
description: 'verbose logging',
type: 'boolean'
});
yargs.options('json', {
description: 'output json to stdout',
type: 'boolean',
alias: ['j']
})
.recommendCommands()
.showHelpOnFail()
.help()
.epilog(chalk.bold('for more information visit http://hkube.org'))
.completion();
yargs.middleware((args) => {
global.args = args;
setupClient(global.args);
});
const args = await yargs.argv;
if (!args._[0]) {
if (args.endpoint) {
yargs.showHelp();
}
else {
config.handler(args);
}
}
};
module.exports = main;