Skip to content

Commit

Permalink
Allow skip cluster (#691)
Browse files Browse the repository at this point in the history
* allow to install runtime without adding cluster integration

* wip
  • Loading branch information
roi-codefresh authored Jul 4, 2021
1 parent 222083f commit 1b1f172
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
21 changes: 13 additions & 8 deletions lib/interface/cli/commands/runtimeEnvironments/install.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}),
Expand All @@ -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,
Expand Down Expand Up @@ -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({
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.75.28",
"version": "0.75.29",
"description": "Codefresh command line utility",
"main": "index.js",
"preferGlobal": true,
Expand Down

0 comments on commit 1b1f172

Please sign in to comment.