@@ -92,7 +92,7 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.auth</code></h1>
92
92
self.server = server
93
93
self.skip_tls = skip_tls
94
94
95
- def login(self):
95
+ def login(self) -> str :
96
96
"""
97
97
This function is used to login to an OpenShift cluster using the user's API token and API server address.
98
98
Depending on the cluster, a user can choose to login in with "--insecure-skip-tls-verify` by setting `skip_tls`
@@ -107,15 +107,18 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.auth</code></h1>
107
107
error_msg = osp.result.err()
108
108
if "The server uses a certificate signed by unknown authority" in error_msg:
109
109
return "Error: certificate auth failure, please set `skip_tls=True` in TokenAuthentication"
110
+ elif "invalid" in error_msg:
111
+ raise PermissionError(error_msg)
110
112
else:
111
113
return error_msg
112
114
return response.out()
113
115
114
- def logout(self):
116
+ def logout(self) -> str :
115
117
"""
116
118
This function is used to logout of an OpenShift cluster.
117
119
"""
118
- response = oc.invoke("logout")
120
+ args = [f"--token={self.token}", f"--server={self.server}:6443"]
121
+ response = oc.invoke("logout", args)
119
122
return response.out()
120
123
121
124
@@ -137,14 +140,14 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.auth</code></h1>
137
140
self.username = username
138
141
self.password = password
139
142
140
- def login(self):
143
+ def login(self) -> str :
141
144
"""
142
145
This function is used to login to an OpenShift cluster using the user's `username` and `password`.
143
146
"""
144
147
response = oc.login(self.username, self.password)
145
148
return response.out()
146
149
147
- def logout(self):
150
+ def logout(self) -> str :
148
151
"""
149
152
This function is used to logout of an OpenShift cluster.
150
153
"""
@@ -261,14 +264,14 @@ <h3>Methods</h3>
261
264
self.username = username
262
265
self.password = password
263
266
264
- def login(self):
267
+ def login(self) -> str :
265
268
"""
266
269
This function is used to login to an OpenShift cluster using the user's `username` and `password`.
267
270
"""
268
271
response = oc.login(self.username, self.password)
269
272
return response.out()
270
273
271
- def logout(self):
274
+ def logout(self) -> str :
272
275
"""
273
276
This function is used to logout of an OpenShift cluster.
274
277
"""
@@ -282,15 +285,15 @@ <h3>Ancestors</h3>
282
285
< h3 > Methods</ h3 >
283
286
< dl >
284
287
< dt id ="codeflare_sdk.cluster.auth.PasswordUserAuthentication.login "> < code class ="name flex ">
285
- < span > def < span class ="ident "> login</ span > </ span > (< span > self)</ span >
288
+ < span > def < span class ="ident "> login</ span > </ span > (< span > self) ‑ > str </ span >
286
289
</ code > </ dt >
287
290
< dd >
288
291
< div class ="desc "> < p > This function is used to login to an OpenShift cluster using the user's < code > username</ code > and < code > password</ code > .</ p > </ div >
289
292
< details class ="source ">
290
293
< summary >
291
294
< span > Expand source code</ span >
292
295
</ summary >
293
- < pre > < code class ="python "> def login(self):
296
+ < pre > < code class ="python "> def login(self) -> str :
294
297
"""
295
298
This function is used to login to an OpenShift cluster using the user's `username` and `password`.
296
299
"""
@@ -299,15 +302,15 @@ <h3>Methods</h3>
299
302
</ details >
300
303
</ dd >
301
304
< dt id ="codeflare_sdk.cluster.auth.PasswordUserAuthentication.logout "> < code class ="name flex ">
302
- < span > def < span class ="ident "> logout</ span > </ span > (< span > self)</ span >
305
+ < span > def < span class ="ident "> logout</ span > </ span > (< span > self) ‑ > str </ span >
303
306
</ code > </ dt >
304
307
< dd >
305
308
< div class ="desc "> < p > This function is used to logout of an OpenShift cluster.</ p > </ div >
306
309
< details class ="source ">
307
310
< summary >
308
311
< span > Expand source code</ span >
309
312
</ summary >
310
- < pre > < code class ="python "> def logout(self):
313
+ < pre > < code class ="python "> def logout(self) -> str :
311
314
"""
312
315
This function is used to logout of an OpenShift cluster.
313
316
"""
@@ -346,7 +349,7 @@ <h3>Methods</h3>
346
349
self.server = server
347
350
self.skip_tls = skip_tls
348
351
349
- def login(self):
352
+ def login(self) -> str :
350
353
"""
351
354
This function is used to login to an OpenShift cluster using the user's API token and API server address.
352
355
Depending on the cluster, a user can choose to login in with "--insecure-skip-tls-verify` by setting `skip_tls`
@@ -361,15 +364,18 @@ <h3>Methods</h3>
361
364
error_msg = osp.result.err()
362
365
if "The server uses a certificate signed by unknown authority" in error_msg:
363
366
return "Error: certificate auth failure, please set `skip_tls=True` in TokenAuthentication"
367
+ elif "invalid" in error_msg:
368
+ raise PermissionError(error_msg)
364
369
else:
365
370
return error_msg
366
371
return response.out()
367
372
368
- def logout(self):
373
+ def logout(self) -> str :
369
374
"""
370
375
This function is used to logout of an OpenShift cluster.
371
376
"""
372
- response = oc.invoke("logout")
377
+ args = [f"--token={self.token}", f"--server={self.server}:6443"]
378
+ response = oc.invoke("logout", args)
373
379
return response.out()</ code > </ pre >
374
380
</ details >
375
381
< h3 > Ancestors</ h3 >
@@ -379,7 +385,7 @@ <h3>Ancestors</h3>
379
385
< h3 > Methods</ h3 >
380
386
< dl >
381
387
< dt id ="codeflare_sdk.cluster.auth.TokenAuthentication.login "> < code class ="name flex ">
382
- < span > def < span class ="ident "> login</ span > </ span > (< span > self)</ span >
388
+ < span > def < span class ="ident "> login</ span > </ span > (< span > self) ‑ > str </ span >
383
389
</ code > </ dt >
384
390
< dd >
385
391
< div class ="desc "> < p > This function is used to login to an OpenShift cluster using the user's API token and API server address.
@@ -389,7 +395,7 @@ <h3>Methods</h3>
389
395
< summary >
390
396
< span > Expand source code</ span >
391
397
</ summary >
392
- < pre > < code class ="python "> def login(self):
398
+ < pre > < code class ="python "> def login(self) -> str :
393
399
"""
394
400
This function is used to login to an OpenShift cluster using the user's API token and API server address.
395
401
Depending on the cluster, a user can choose to login in with "--insecure-skip-tls-verify` by setting `skip_tls`
@@ -404,25 +410,28 @@ <h3>Methods</h3>
404
410
error_msg = osp.result.err()
405
411
if "The server uses a certificate signed by unknown authority" in error_msg:
406
412
return "Error: certificate auth failure, please set `skip_tls=True` in TokenAuthentication"
413
+ elif "invalid" in error_msg:
414
+ raise PermissionError(error_msg)
407
415
else:
408
416
return error_msg
409
417
return response.out()</ code > </ pre >
410
418
</ details >
411
419
</ dd >
412
420
< dt id ="codeflare_sdk.cluster.auth.TokenAuthentication.logout "> < code class ="name flex ">
413
- < span > def < span class ="ident "> logout</ span > </ span > (< span > self)</ span >
421
+ < span > def < span class ="ident "> logout</ span > </ span > (< span > self) ‑ > str </ span >
414
422
</ code > </ dt >
415
423
< dd >
416
424
< div class ="desc "> < p > This function is used to logout of an OpenShift cluster.</ p > </ div >
417
425
< details class ="source ">
418
426
< summary >
419
427
< span > Expand source code</ span >
420
428
</ summary >
421
- < pre > < code class ="python "> def logout(self):
429
+ < pre > < code class ="python "> def logout(self) -> str :
422
430
"""
423
431
This function is used to logout of an OpenShift cluster.
424
432
"""
425
- response = oc.invoke("logout")
433
+ args = [f"--token={self.token}", f"--server={self.server}:6443"]
434
+ response = oc.invoke("logout", args)
426
435
return response.out()</ code > </ pre >
427
436
</ details >
428
437
</ dd >
0 commit comments