Skip to content

Commit

Permalink
update envvar on the runtimeScheduler (#545)
Browse files Browse the repository at this point in the history
* update envvar on the runtimeScheduler

* fix
  • Loading branch information
oren-codefresh authored Jul 30, 2020
1 parent 743aa26 commit 78fcb35
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions lib/interface/cli/commands/hybrid/init.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,27 @@ const initCmd = new Command({
condition: !!dockerRegistry,
});

// update env vars
installationPlan.addStep({
name: 'update runtime environment with env vars',
func: async () => {
const reName = installationPlan.getContext('runtimeName');
const re = await sdk.runtimeEnvs.get({ name: reName });
let currentEnvVars = _.get(re, 'runtimeScheduler.envVars', {});
const envVarsAsObject = envVars.reduce((acc, current) => {
const parts = current.split('=');
// eslint-disable-next-line prefer-destructuring
acc[parts[0]] = parts[1];
return acc;
}, {});
currentEnvVars = _.merge(currentEnvVars, envVarsAsObject);
const body = _.set(re, 'runtimeScheduler.envVars', currentEnvVars);
await sdk.runtimeEnvs.update({ name: reName }, _.merge(re, body));
console.log(`Runtime environment "${colors.cyan(reName)}" has been updated with env vars`);
},
condition: !!envVars,
});

// set runtime as default
installationPlan.addStep({
name: 'set new runtime as default',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codefresh",
"version": "0.71.6",
"version": "0.71.7",
"description": "Codefresh command line utility",
"main": "index.js",
"preferGlobal": true,
Expand Down

0 comments on commit 78fcb35

Please sign in to comment.