From 1b1f172c96e93ddb7b866aba52903d54272b068a Mon Sep 17 00:00:00 2001 From: roi-codefresh <60569147+roi-codefresh@users.noreply.github.com> Date: Sun, 4 Jul 2021 08:58:47 +0300 Subject: [PATCH] Allow skip cluster (#691) * allow to install runtime without adding cluster integration * wip --- .../runtimeEnvironments/install.cmd.js | 21 ++++++++++++------- package.json | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/interface/cli/commands/runtimeEnvironments/install.cmd.js b/lib/interface/cli/commands/runtimeEnvironments/install.cmd.js index 66402348e..ce849c826 100644 --- a/lib/interface/cli/commands/runtimeEnvironments/install.cmd.js +++ b/lib/interface/cli/commands/runtimeEnvironments/install.cmd.js @@ -112,6 +112,9 @@ const installRuntimeCmd = new Command({ .option('make-default-runtime', { describe: 'should all pipelines run on the this runtime (default is false)', }) + .option('skip-cluster-creation', { + description: 'If set to true, will skip cluster integration creation for this runtime', + }) .option('verbose', { describe: 'Print logs', }), @@ -121,6 +124,7 @@ const installRuntimeCmd = new Command({ 'agent-name': agentName, 'runtime-name': reName, 'skip-re-creation': skipRuntimeCreation, + 'skip-cluster-creation': skipClusterCreation, 'dry-run': dryRun, 'in-cluster': inCluster, 'kube-node-selector': kubeNodeSelector, @@ -200,18 +204,19 @@ const installRuntimeCmd = new Command({ } // check if cluster already exists - let clusterExists = false; - try { - const clusters = await sdk.clusters.list() || []; - if (clusters.find(cluster => cluster.selector === kubeContextName)) { - clusterExists = true; + let createCluster = false; + if (!skipClusterCreation) { + try { + const clusters = await sdk.clusters.list() || []; + // should create cluster if it does not exist already + createCluster = !clusters.find(cluster => cluster.selector === kubeContextName); + } catch (error) { + console.log(`Failed to fetch account clusters, cause: ${error.message}`); } - } catch (error) { - console.log(`Failed to fetch account clusters, cause: ${error.message}`); } // create the cluster in codefresh if does not exists - if (!clusterExists) { + if (createCluster) { console.log(`Adding cluster "${colors.cyan(kubeContextName)}" integration to your Codefresh account`); try { await createClusterCmd.handler({ diff --git a/package.json b/package.json index d62b2f9ac..3b9bf0b08 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codefresh", - "version": "0.75.28", + "version": "0.75.29", "description": "Codefresh command line utility", "main": "index.js", "preferGlobal": true,