File tree 1 file changed +9
-6
lines changed
src/codeflare_sdk/cluster
1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change 21
21
22
22
import abc
23
23
from kubernetes import client , config
24
+ import os
24
25
25
26
global api_client
26
27
api_client = None
@@ -161,14 +162,16 @@ def config_check() -> str:
161
162
"""
162
163
global config_path
163
164
global api_client
165
+ home_directory = os .path .expanduser ("~" )
164
166
if config_path == None and api_client == None :
165
- try :
167
+ if os . path . isfile ( "%s/.kube/config" % home_directory ) :
166
168
config .load_kube_config ()
167
- except config .config_exception .ConfigException :
168
- try :
169
- config .load_incluster_config ()
170
- except :
171
- print ("Unable to load config file or in cluster configuration" )
169
+ elif "KUBERNETES_PORT" in os .environ :
170
+ config .load_incluster_config ()
171
+ else :
172
+ print (
173
+ "Unable to load config file or in cluster configuration, try specifying a config file path with load_kube_config()"
174
+ )
172
175
173
176
if config_path != None and api_client == None :
174
177
return config_path
You can’t perform that action at this time.
0 commit comments