Skip to content

Commit e3df6a0

Browse files
olegs-codefreshitai-codefresh
authored andcommitted
Add set flag to install chart cmd (#111)
1 parent 10d7dd7 commit e3df6a0

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

lib/interface/cli/commands/pipeline/dynamic/install-chart.cmd.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ const install = new Command({
5757
description: 'Contexts (yaml || secret-yaml) to be passed to the install',
5858
array: true,
5959
})
60+
.option('set', {
61+
description: 'set of KEY=VALUE to be passed to the install',
62+
array: true,
63+
})
6064
.option('detach', {
6165
alias: 'd',
6266
describe: 'Run pipeline and print build ID',
@@ -76,6 +80,7 @@ const install = new Command({
7680
version: argv.version,
7781
values: argv.context,
7882
tillerNamespace: argv.tillerNamespace,
83+
setValues: argv.set,
7984
});
8085
if (argv.detach) {
8186
console.log(workflowId);

lib/logic/api/helm.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,23 @@ const _normalizeValues = async (values = []) => {
3737
return normalizedValues;
3838
};
3939

40+
const _normalizeSetValues = async (values = []) => {
41+
const normalizedValues = await Promise.reduce(values, async (normalized, givenValue) => {
42+
const [key, value] = givenValue.split('=');
43+
if (!key || !value) {
44+
throw new Error('Passed set value must be in format KEY=VALUE');
45+
}
46+
const setObject = {
47+
key,
48+
value,
49+
};
50+
normalized.push(setObject);
51+
return normalized;
52+
}, []);
53+
54+
return normalizedValues;
55+
};
56+
4057
const installChart = async ({
4158
cluster,
4259
namespace,
@@ -46,8 +63,10 @@ const installChart = async ({
4663
values,
4764
releaseName,
4865
tillerNamespace,
66+
setValues,
4967
}) => {
5068
const normalizedValues = await _normalizeValues(values);
69+
const normalizedSetValues = await _normalizeSetValues(setValues);
5170
const options = {
5271
url: '/api/kubernetes/chart/install',
5372
method: 'POST',
@@ -62,6 +81,7 @@ const installChart = async ({
6281
values: normalizedValues,
6382
version,
6483
releaseName,
84+
set: normalizedSetValues,
6585
},
6686
};
6787

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.8.2",
3+
"version": "0.8.3",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)