Skip to content

Commit 438da28

Browse files
Bobbins228openshift-merge-robot
authored andcommitted
Added exception handling to config methods
1 parent c23b3d6 commit 438da28

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/codeflare_sdk/cluster/auth.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,18 @@ def config_check() -> str:
165165
home_directory = os.path.expanduser("~")
166166
if config_path == None and api_client == None:
167167
if os.path.isfile("%s/.kube/config" % home_directory):
168-
config.load_kube_config()
168+
try:
169+
config.load_kube_config()
170+
except Exception as e:
171+
print(e)
169172
elif "KUBERNETES_PORT" in os.environ:
170-
config.load_incluster_config()
173+
try:
174+
config.load_incluster_config()
175+
except Exception as e:
176+
print(e)
171177
else:
172-
print(
173-
"Unable to load config file or in cluster configuration, try specifying a config file path with load_kube_config()"
178+
raise PermissionError(
179+
"Action not permitted, have you put in correct/up-to-date auth credentials?"
174180
)
175181

176182
if config_path != None and api_client == None:

0 commit comments

Comments
 (0)