From 78fcb353b73638cb03484d58fa4e052a2029172d Mon Sep 17 00:00:00 2001 From: oren-codefresh Date: Thu, 30 Jul 2020 08:35:25 +0300 Subject: [PATCH] update envvar on the runtimeScheduler (#545) * update envvar on the runtimeScheduler * fix --- lib/interface/cli/commands/hybrid/init.cmd.js | 21 +++++++++++++++++++ package.json | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/interface/cli/commands/hybrid/init.cmd.js b/lib/interface/cli/commands/hybrid/init.cmd.js index 34a20c03f..ed4ea696d 100644 --- a/lib/interface/cli/commands/hybrid/init.cmd.js +++ b/lib/interface/cli/commands/hybrid/init.cmd.js @@ -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', diff --git a/package.json b/package.json index 0e74960ac..0140bf4d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codefresh", - "version": "0.71.6", + "version": "0.71.7", "description": "Codefresh command line utility", "main": "index.js", "preferGlobal": true,