Skip to content

Commit 7bff6c5

Browse files
author
Oleg Sucharevich
authored
add cluster --name-overwrite and --behind-firewall flags (#248)
* add flags to allow overwrite the name of the cluster and to spesify if the cluster is behind firewall
1 parent e863270 commit 7bff6c5

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

lib/interface/cli/commands/cluster/create.cmd.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,32 @@ const command = new Command({
3333
default: 'default',
3434
required: true,
3535
})
36+
.option('name-overwrite', {
37+
describe: 'spesify under which name the cluster should be saved in Codefresh, default is the context name',
38+
})
39+
.option('behind-firewall', {
40+
describe: 'Spesify whenever the cluster is behined firewall',
41+
default: false,
42+
type: 'boolean',
43+
})
3644
.example('codefresh create cluster --kube-context production', 'Creating a cluster in codefresh');
3745
},
3846
handler: async (argv) => {
3947
const context = authManager.getCurrentContext();
40-
const { namespace, serviceaccount, 'kube-context': name } = argv;
48+
const {
49+
namespace,
50+
serviceaccount,
51+
'kube-context': contextName,
52+
'behind-firewall': behindFirewall,
53+
'name-overwrite': name,
54+
} = argv;
4155
await cluster.createCluster({
42-
name,
56+
contextName,
4357
context,
4458
namespace,
4559
serviceaccount,
60+
behindFirewall,
61+
name,
4662
});
4763
},
4864
});

lib/logic/api/cluster.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,36 @@ const { CODEFRESH_PATH } = require('../../interface/cli/defaults');
1414

1515
const _createClusterScript = (info, filePath) => {
1616
const {
17+
contextName,
1718
name,
19+
behindFirewall,
1820
context,
1921
namespace,
2022
serviceaccount,
2123
} = info;
2224
fs.chmodSync(filePath, '755');
23-
const clusterScript = spawn(filePath, ['create', '--c', name, '--token', context.token, '--api-host', `${context.url}/`, '--namespace', namespace, '--serviceaccount', serviceaccount]);
25+
const commands = [
26+
'create',
27+
'--c',
28+
contextName,
29+
'--token',
30+
context.token,
31+
'--api-host',
32+
`${context.url}/`,
33+
'--namespace',
34+
namespace,
35+
'--serviceaccount',
36+
serviceaccount,
37+
];
38+
if (name) {
39+
commands.push('--name-overwrite');
40+
commands.push(name);
41+
}
42+
43+
if (behindFirewall) {
44+
commands.push('--behind-firewall');
45+
}
46+
const clusterScript = spawn(filePath, commands);
2447
clusterScript.stdout.pipe(process.stdout);
2548
clusterScript.stderr.pipe(process.stderr);
2649
process.stdin.pipe(clusterScript.stdin);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codefresh",
3-
"version": "0.9.3",
3+
"version": "0.9.4",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)