Skip to content

Commit e863270

Browse files
author
Oleg Sucharevich
authored
Overwrite namespace serviceaccount (#247)
* allow overwriting namespace and service account when running stevedore
1 parent 377a779 commit e863270

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,28 @@ const command = new Command({
2121
alias: 'kc',
2222
required: true,
2323
})
24+
.option('namespace', {
25+
describe: 'Kubernetes namespace to use while looking for service account',
26+
alias: 'ns',
27+
default: 'default',
28+
required: true,
29+
})
30+
.option('serviceaccount', {
31+
describe: 'Kubernetes serviceaccount credentials to be added to Codefresh',
32+
alias: 'sa',
33+
default: 'default',
34+
required: true,
35+
})
2436
.example('codefresh create cluster --kube-context production', 'Creating a cluster in codefresh');
2537
},
2638
handler: async (argv) => {
2739
const context = authManager.getCurrentContext();
28-
const name = argv['kube-context'];
40+
const { namespace, serviceaccount, 'kube-context': name } = argv;
2941
await cluster.createCluster({
3042
name,
3143
context,
44+
namespace,
45+
serviceaccount,
3246
});
3347
},
3448
});

lib/logic/api/cluster.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@ const compareVersions = require('compare-versions');
1313
const { CODEFRESH_PATH } = require('../../interface/cli/defaults');
1414

1515
const _createClusterScript = (info, filePath) => {
16-
const { name, context } = info;
16+
const {
17+
name,
18+
context,
19+
namespace,
20+
serviceaccount,
21+
} = info;
1722
fs.chmodSync(filePath, '755');
18-
const clusterScript = spawn(filePath, ['create', '--c', name, '--token', context.token, '--api-host', `${context.url}/`] );
23+
const clusterScript = spawn(filePath, ['create', '--c', name, '--token', context.token, '--api-host', `${context.url}/`, '--namespace', namespace, '--serviceaccount', serviceaccount]);
1924
clusterScript.stdout.pipe(process.stdout);
2025
clusterScript.stderr.pipe(process.stderr);
2126
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.2",
3+
"version": "0.9.3",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)