Skip to content

Commit 6c85148

Browse files
update auth to allow for skip_tls
1 parent 8feb136 commit 6c85148

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/codeflare_sdk/cluster/auth.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,23 @@ def __init__(
6161
self.token = token
6262
self.server = server
6363

64-
def login(self):
64+
def login(self, skip_tls=False):
6565
"""
6666
This function is used to login to an OpenShift cluster using the user's API token and API server address.
67+
Depending on the cluster, a user can choose to login in with "--insecure-skip-tls-verify` by setting `skip_tls`
68+
to `True`.
6769
"""
6870
token = self.token
6971
server = self.server
70-
response = oc.invoke("login", [f"--token={token}", f"--server={server}:6443"])
72+
args = [f"--token={token}", f"--server={server}:6443"]
73+
if skip_tls:
74+
args.append("--insecure-skip-tls-verify")
75+
response = oc.invoke("login", args)
76+
if (
77+
"The server uses a certificate signed by unknown authority"
78+
in response.err()
79+
):
80+
return "Error: certificate auth failure, please set `skip_tls=True`"
7181
return response.out()
7282

7383
def logout(self):

0 commit comments

Comments
 (0)