Skip to content

Commit b374c50

Browse files
fix cluster integration created by monitor components (#625)
* fix cluster integration created by monitor components * ci
1 parent 2011724 commit b374c50

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

lib/interface/cli/commands/hybrid/init.cmd.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ const initCmd = new Command({
636636
installationEvent: installationProgress.events.CLUSTER_INTEGRATION_ADDED,
637637
condition: async () => {
638638
if (isInCluster()) {
639-
console.log('Cluster integration was not added , please add it via codefresh create clusters [name] ');
639+
console.log('Cluster integration was not added , please add it via codefresh "create clusters [name]"');
640640
return false;
641641
}
642642
const clusters = await sdk.clusters.list() || [];
@@ -778,7 +778,18 @@ const initCmd = new Command({
778778
},
779779
successMessage: 'Successfully installed cluster monitoring',
780780
installationEvent: installationProgress.events.MONITOR_INSTALLED,
781-
condition: installMonitor,
781+
condition: async () => {
782+
if (!installMonitor) {
783+
return false;
784+
}
785+
786+
if (isInCluster()) {
787+
console.log('Monitor component cannot be installed without cluster integration, you can install it seperately using: "codefresh install monitor"');
788+
return false;
789+
}
790+
791+
return true;
792+
},
782793
});
783794

784795
// Post Installation

lib/interface/cli/commands/monitor/install.cmd.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const installRoot = require('../root/install.cmd');
44
const { DefaultLogFormatter } = require('./../hybrid/helper');
55
const { downloadVeonona } = require('../hybrid/helper');
66
const { Runner, components } = require('../../../../binary');
7+
const sdk = require('../../../../logic/sdk');
78
const _ = require('lodash');
89

910
const installMonitorCmd = new Command({
@@ -77,9 +78,11 @@ const installMonitorCmd = new Command({
7778
commands.push(clusterId);
7879
}
7980

81+
commands.push('--codefreshToken');
8082
if (token) {
81-
commands.push('--codefreshToken');
8283
commands.push(token);
84+
} else {
85+
commands.push(_.get(sdk, 'config.context.token'));
8386
}
8487

8588
if (kubeConfigPath) {

lib/interface/cli/helpers/kubernetes.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ const _getKubeConfig = (kubeconfigPath) => {
1717
return kc;
1818
};
1919

20-
const isInCluster = () => {
21-
return fs.existsSync('/var/run/secrets/kubernetes.io/serviceaccount');
22-
};
20+
const isInCluster = () => fs.existsSync('/var/run/secrets/kubernetes.io/serviceaccount');
2321

2422
const getKubeContext = (kubeconfigPath) => {
2523
const kubeconfig = _getKubeConfig(kubeconfigPath);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codefresh",
3-
"version": "0.74.5",
3+
"version": "0.74.6",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)