Skip to content

Commit 4fc5482

Browse files
Changes in docs for release: v0.21.1
1 parent 1a95a15 commit 4fc5482

File tree

6 files changed

+106
-144
lines changed

6 files changed

+106
-144
lines changed

Diff for: docs/detailed-documentation/cluster/auth.html

+56-88
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,7 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.auth</code></h1>
126126
self.token = token
127127
self.server = server
128128
self.skip_tls = skip_tls
129-
self.ca_cert_path = self._gen_ca_cert_path(ca_cert_path)
130-
131-
def _gen_ca_cert_path(self, ca_cert_path: str):
132-
if ca_cert_path is not None:
133-
return ca_cert_path
134-
elif &#34;CF_SDK_CA_CERT_PATH&#34; in os.environ:
135-
return os.environ.get(&#34;CF_SDK_CA_CERT_PATH&#34;)
136-
elif os.path.exists(WORKBENCH_CA_CERT_PATH):
137-
return WORKBENCH_CA_CERT_PATH
138-
else:
139-
return None
129+
self.ca_cert_path = _gen_ca_cert_path(ca_cert_path)
140130

141131
def login(self) -&gt; str:
142132
&#34;&#34;&#34;
@@ -152,25 +142,14 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.auth</code></h1>
152142
configuration.host = self.server
153143
configuration.api_key[&#34;authorization&#34;] = self.token
154144

145+
api_client = client.ApiClient(configuration)
155146
if not self.skip_tls:
156-
if self.ca_cert_path is None:
157-
configuration.ssl_ca_cert = None
158-
elif os.path.isfile(self.ca_cert_path):
159-
print(
160-
f&#34;Authenticated with certificate located at {self.ca_cert_path}&#34;
161-
)
162-
configuration.ssl_ca_cert = self.ca_cert_path
163-
else:
164-
raise FileNotFoundError(
165-
f&#34;Certificate file not found at {self.ca_cert_path}&#34;
166-
)
167-
configuration.verify_ssl = True
147+
_client_with_cert(api_client, self.ca_cert_path)
168148
else:
169149
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
170150
print(&#34;Insecure request warnings have been disabled&#34;)
171151
configuration.verify_ssl = False
172152

173-
api_client = client.ApiClient(configuration)
174153
client.AuthenticationApi(api_client).get_api_group()
175154
config_path = None
176155
return &#34;Logged into %s&#34; % self.server
@@ -244,14 +223,36 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.auth</code></h1>
244223
return config_path
245224

246225

247-
def api_config_handler() -&gt; Optional[client.ApiClient]:
248-
&#34;&#34;&#34;
249-
This function is used to load the api client if the user has logged in
250-
&#34;&#34;&#34;
251-
if api_client != None and config_path == None:
252-
return api_client
226+
def _client_with_cert(client: client.ApiClient, ca_cert_path: Optional[str] = None):
227+
client.configuration.verify_ssl = True
228+
cert_path = _gen_ca_cert_path(ca_cert_path)
229+
if cert_path is None:
230+
client.configuration.ssl_ca_cert = None
231+
elif os.path.isfile(cert_path):
232+
client.configuration.ssl_ca_cert = cert_path
253233
else:
254-
return None</code></pre>
234+
raise FileNotFoundError(f&#34;Certificate file not found at {cert_path}&#34;)
235+
236+
237+
def _gen_ca_cert_path(ca_cert_path: Optional[str]):
238+
&#34;&#34;&#34;Gets the path to the default CA certificate file either through env config or default path&#34;&#34;&#34;
239+
if ca_cert_path is not None:
240+
return ca_cert_path
241+
elif &#34;CF_SDK_CA_CERT_PATH&#34; in os.environ:
242+
return os.environ.get(&#34;CF_SDK_CA_CERT_PATH&#34;)
243+
elif os.path.exists(WORKBENCH_CA_CERT_PATH):
244+
return WORKBENCH_CA_CERT_PATH
245+
else:
246+
return None
247+
248+
249+
def get_api_client() -&gt; client.ApiClient:
250+
&#34;This function should load the api client with defaults&#34;
251+
if api_client != None:
252+
return api_client
253+
to_return = client.ApiClient()
254+
_client_with_cert(to_return)
255+
return to_return</code></pre>
255256
</details>
256257
</section>
257258
<section>
@@ -261,25 +262,6 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.auth</code></h1>
261262
<section>
262263
<h2 class="section-title" id="header-functions">Functions</h2>
263264
<dl>
264-
<dt id="codeflare_sdk.cluster.auth.api_config_handler"><code class="name flex">
265-
<span>def <span class="ident">api_config_handler</span></span>(<span>) ‑> Optional[kubernetes.client.api_client.ApiClient]</span>
266-
</code></dt>
267-
<dd>
268-
<div class="desc"><p>This function is used to load the api client if the user has logged in</p></div>
269-
<details class="source">
270-
<summary>
271-
<span>Expand source code</span>
272-
</summary>
273-
<pre><code class="python">def api_config_handler() -&gt; Optional[client.ApiClient]:
274-
&#34;&#34;&#34;
275-
This function is used to load the api client if the user has logged in
276-
&#34;&#34;&#34;
277-
if api_client != None and config_path == None:
278-
return api_client
279-
else:
280-
return None</code></pre>
281-
</details>
282-
</dd>
283265
<dt id="codeflare_sdk.cluster.auth.config_check"><code class="name flex">
284266
<span>def <span class="ident">config_check</span></span>(<span>) ‑> str</span>
285267
</code></dt>
@@ -318,6 +300,24 @@ <h2 class="section-title" id="header-functions">Functions</h2>
318300
return config_path</code></pre>
319301
</details>
320302
</dd>
303+
<dt id="codeflare_sdk.cluster.auth.get_api_client"><code class="name flex">
304+
<span>def <span class="ident">get_api_client</span></span>(<span>) ‑> kubernetes.client.api_client.ApiClient</span>
305+
</code></dt>
306+
<dd>
307+
<div class="desc"><p>This function should load the api client with defaults</p></div>
308+
<details class="source">
309+
<summary>
310+
<span>Expand source code</span>
311+
</summary>
312+
<pre><code class="python">def get_api_client() -&gt; client.ApiClient:
313+
&#34;This function should load the api client with defaults&#34;
314+
if api_client != None:
315+
return api_client
316+
to_return = client.ApiClient()
317+
_client_with_cert(to_return)
318+
return to_return</code></pre>
319+
</details>
320+
</dd>
321321
</dl>
322322
</section>
323323
<section>
@@ -573,17 +573,7 @@ <h3>Methods</h3>
573573
self.token = token
574574
self.server = server
575575
self.skip_tls = skip_tls
576-
self.ca_cert_path = self._gen_ca_cert_path(ca_cert_path)
577-
578-
def _gen_ca_cert_path(self, ca_cert_path: str):
579-
if ca_cert_path is not None:
580-
return ca_cert_path
581-
elif &#34;CF_SDK_CA_CERT_PATH&#34; in os.environ:
582-
return os.environ.get(&#34;CF_SDK_CA_CERT_PATH&#34;)
583-
elif os.path.exists(WORKBENCH_CA_CERT_PATH):
584-
return WORKBENCH_CA_CERT_PATH
585-
else:
586-
return None
576+
self.ca_cert_path = _gen_ca_cert_path(ca_cert_path)
587577

588578
def login(self) -&gt; str:
589579
&#34;&#34;&#34;
@@ -599,25 +589,14 @@ <h3>Methods</h3>
599589
configuration.host = self.server
600590
configuration.api_key[&#34;authorization&#34;] = self.token
601591

592+
api_client = client.ApiClient(configuration)
602593
if not self.skip_tls:
603-
if self.ca_cert_path is None:
604-
configuration.ssl_ca_cert = None
605-
elif os.path.isfile(self.ca_cert_path):
606-
print(
607-
f&#34;Authenticated with certificate located at {self.ca_cert_path}&#34;
608-
)
609-
configuration.ssl_ca_cert = self.ca_cert_path
610-
else:
611-
raise FileNotFoundError(
612-
f&#34;Certificate file not found at {self.ca_cert_path}&#34;
613-
)
614-
configuration.verify_ssl = True
594+
_client_with_cert(api_client, self.ca_cert_path)
615595
else:
616596
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
617597
print(&#34;Insecure request warnings have been disabled&#34;)
618598
configuration.verify_ssl = False
619599

620-
api_client = client.ApiClient(configuration)
621600
client.AuthenticationApi(api_client).get_api_group()
622601
config_path = None
623602
return &#34;Logged into %s&#34; % self.server
@@ -665,25 +644,14 @@ <h3>Methods</h3>
665644
configuration.host = self.server
666645
configuration.api_key[&#34;authorization&#34;] = self.token
667646

647+
api_client = client.ApiClient(configuration)
668648
if not self.skip_tls:
669-
if self.ca_cert_path is None:
670-
configuration.ssl_ca_cert = None
671-
elif os.path.isfile(self.ca_cert_path):
672-
print(
673-
f&#34;Authenticated with certificate located at {self.ca_cert_path}&#34;
674-
)
675-
configuration.ssl_ca_cert = self.ca_cert_path
676-
else:
677-
raise FileNotFoundError(
678-
f&#34;Certificate file not found at {self.ca_cert_path}&#34;
679-
)
680-
configuration.verify_ssl = True
649+
_client_with_cert(api_client, self.ca_cert_path)
681650
else:
682651
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
683652
print(&#34;Insecure request warnings have been disabled&#34;)
684653
configuration.verify_ssl = False
685654

686-
api_client = client.ApiClient(configuration)
687655
client.AuthenticationApi(api_client).get_api_group()
688656
config_path = None
689657
return &#34;Logged into %s&#34; % self.server
@@ -729,8 +697,8 @@ <h1>Index</h1>
729697
</li>
730698
<li><h3><a href="#header-functions">Functions</a></h3>
731699
<ul class="">
732-
<li><code><a title="codeflare_sdk.cluster.auth.api_config_handler" href="#codeflare_sdk.cluster.auth.api_config_handler">api_config_handler</a></code></li>
733700
<li><code><a title="codeflare_sdk.cluster.auth.config_check" href="#codeflare_sdk.cluster.auth.config_check">config_check</a></code></li>
701+
<li><code><a title="codeflare_sdk.cluster.auth.get_api_client" href="#codeflare_sdk.cluster.auth.get_api_client">get_api_client</a></code></li>
734702
</ul>
735703
</li>
736704
<li><h3><a href="#header-classes">Classes</a></h3>

Diff for: docs/detailed-documentation/cluster/awload.html

+7-7
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.awload</code></h1>
5555

5656
from kubernetes import client, config
5757
from ..utils.kube_api_helpers import _kube_api_error_handling
58-
from .auth import config_check, api_config_handler
58+
from .auth import config_check, get_api_client
5959

6060

6161
class AWManager:
@@ -90,7 +90,7 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.awload</code></h1>
9090
&#34;&#34;&#34;
9191
try:
9292
config_check()
93-
api_instance = client.CustomObjectsApi(api_config_handler())
93+
api_instance = client.CustomObjectsApi(get_api_client())
9494
api_instance.create_namespaced_custom_object(
9595
group=&#34;workload.codeflare.dev&#34;,
9696
version=&#34;v1beta2&#34;,
@@ -115,7 +115,7 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.awload</code></h1>
115115

116116
try:
117117
config_check()
118-
api_instance = client.CustomObjectsApi(api_config_handler())
118+
api_instance = client.CustomObjectsApi(get_api_client())
119119
api_instance.delete_namespaced_custom_object(
120120
group=&#34;workload.codeflare.dev&#34;,
121121
version=&#34;v1beta2&#34;,
@@ -184,7 +184,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
184184
&#34;&#34;&#34;
185185
try:
186186
config_check()
187-
api_instance = client.CustomObjectsApi(api_config_handler())
187+
api_instance = client.CustomObjectsApi(get_api_client())
188188
api_instance.create_namespaced_custom_object(
189189
group=&#34;workload.codeflare.dev&#34;,
190190
version=&#34;v1beta2&#34;,
@@ -209,7 +209,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
209209

210210
try:
211211
config_check()
212-
api_instance = client.CustomObjectsApi(api_config_handler())
212+
api_instance = client.CustomObjectsApi(get_api_client())
213213
api_instance.delete_namespaced_custom_object(
214214
group=&#34;workload.codeflare.dev&#34;,
215215
version=&#34;v1beta2&#34;,
@@ -246,7 +246,7 @@ <h3>Methods</h3>
246246

247247
try:
248248
config_check()
249-
api_instance = client.CustomObjectsApi(api_config_handler())
249+
api_instance = client.CustomObjectsApi(get_api_client())
250250
api_instance.delete_namespaced_custom_object(
251251
group=&#34;workload.codeflare.dev&#34;,
252252
version=&#34;v1beta2&#34;,
@@ -276,7 +276,7 @@ <h3>Methods</h3>
276276
&#34;&#34;&#34;
277277
try:
278278
config_check()
279-
api_instance = client.CustomObjectsApi(api_config_handler())
279+
api_instance = client.CustomObjectsApi(get_api_client())
280280
api_instance.create_namespaced_custom_object(
281281
group=&#34;workload.codeflare.dev&#34;,
282282
version=&#34;v1beta2&#34;,

0 commit comments

Comments
 (0)