diff --git a/lib/interface/cli/commands/agent/install.cmd.js b/lib/interface/cli/commands/agent/install.cmd.js index 477c2fa2b..0ef66903c 100644 --- a/lib/interface/cli/commands/agent/install.cmd.js +++ b/lib/interface/cli/commands/agent/install.cmd.js @@ -83,6 +83,9 @@ const installAgentCmd = new Command({ if (!kubeContextName) { kubeContextName = getKubeContext(kubeConfigPath); } + if (!kubeNamespace) { + throw new Error('kube-namespace is mandatory parameter'); + } if (!token) { // Create an agent if not provided name = name || `${kubeContextName}_${kubeNamespace}`; diff --git a/lib/interface/cli/commands/runtimeEnvironments/attach.cmd.js b/lib/interface/cli/commands/runtimeEnvironments/attach.cmd.js index 8ec185269..f626b22f5 100644 --- a/lib/interface/cli/commands/runtimeEnvironments/attach.cmd.js +++ b/lib/interface/cli/commands/runtimeEnvironments/attach.cmd.js @@ -6,11 +6,18 @@ const ProgressEvents = require('../../helpers/progressEvents'); const cliProgress = require('cli-progress'); -const attachAgentToRuntime = async (agent, runtime) => { +const attachAgentToRuntime = async (agent, name) => { + const rt = await sdk.runtimeEnvs.get({ name }); + if (!rt) { + throw new Error(`runtime ${name} does not exist on the account`); + } + if (!rt.metadata.agent) { + throw new Error('cannot attach non hybrid runtime'); + } const runtimes = _.get(agent, 'runtimes', []); - const existingRT = _.find(runtimes, value => value === runtime); + const existingRT = _.find(runtimes, value => value === name); if (!existingRT) { - runtimes.push(runtime); + runtimes.push(name); await sdk.agents.update({ agentId: agent.id, runtimes }); } }; @@ -90,6 +97,9 @@ const attachRuntimeCmd = new Command({ if (agent === '' || !agent) { throw new Error('agent was not found'); } + if (!kubeNamespace) { + throw new Error('runtime-kube-namespace is mandatory parameter'); + } await attachAgentToRuntime(agent, runtimeName); diff --git a/lib/interface/cli/commands/runtimeEnvironments/install.cmd.js b/lib/interface/cli/commands/runtimeEnvironments/install.cmd.js index 4d9adb283..10f7ac86b 100644 --- a/lib/interface/cli/commands/runtimeEnvironments/install.cmd.js +++ b/lib/interface/cli/commands/runtimeEnvironments/install.cmd.js @@ -117,6 +117,11 @@ const installRuntimeCmd = new Command({ 'agent-kube-config-path': agentKubeConfigPath, token, } = argv; + + if (!kubeNamespace) { + throw new Error('runtime-kube-namespace is mandatory parameter'); + } + const apiHost = sdk.config.context.url; const clusterName = kubeContextName || getKubeContext(kubeConfigPath); const runtimeName = `${clusterName}/${kubeNamespace}`; diff --git a/package.json b/package.json index 4ad7358ef..eb0461c99 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codefresh", - "version": "0.43.9", + "version": "0.43.10", "description": "Codefresh command line utility", "main": "index.js",