File tree Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ const inquirer = require('inquirer');
5
5
const colors = require ( 'colors' ) ;
6
6
const _ = require ( 'lodash' ) ;
7
7
const { addProxyVariables, detectProxy, keyValueArrayToObject } = require ( '../../helpers/general' ) ;
8
- const { getAllKubeContexts, getKubeContext } = require ( '../../helpers/kubernetes' ) ;
8
+ const { getAllKubeContexts, getKubeContext, isInCluster } = require ( '../../helpers/kubernetes' ) ;
9
9
const installMonitoring = require ( '../monitor/install.cmd' ) ;
10
10
const createClusterCmd = require ( '../cluster/create.cmd' ) ;
11
11
const createContext = require ( '../auth/create-context.cmd' ) ;
@@ -635,6 +635,10 @@ const initCmd = new Command({
635
635
} ,
636
636
installationEvent : installationProgress . events . CLUSTER_INTEGRATION_ADDED ,
637
637
condition : async ( ) => {
638
+ if ( isInCluster ( ) ) {
639
+ console . log ( 'Cluster integration was not added , please add it via codefresh create clusters [name] ' ) ;
640
+ return false ;
641
+ }
638
642
const clusters = await sdk . clusters . list ( ) || [ ] ;
639
643
if ( clusters . find ( cluster => cluster . selector === kubeContextName ) ) {
640
644
return false ; // cluster already exists
Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ const _getKubeConfig = (kubeconfigPath) => {
17
17
return kc ;
18
18
} ;
19
19
20
+ const isInCluster = ( ) => {
21
+ return fs . existsSync ( '/var/run/secrets/kubernetes.io/serviceaccount' ) ;
22
+ } ;
23
+
20
24
const getKubeContext = ( kubeconfigPath ) => {
21
25
const kubeconfig = _getKubeConfig ( kubeconfigPath ) ;
22
26
return kubeconfig . currentContext ;
@@ -49,4 +53,5 @@ module.exports = {
49
53
getKubeContext,
50
54
getAllKubeContexts,
51
55
getAllNamespaces,
56
+ isInCluster,
52
57
} ;
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " codefresh" ,
3
- "version" : " 0.73.23 " ,
3
+ "version" : " 0.73.24 " ,
4
4
"description" : " Codefresh command line utility" ,
5
5
"main" : " index.js" ,
6
6
"preferGlobal" : true ,
You can’t perform that action at this time.
0 commit comments