@@ -60,8 +60,6 @@ <h1 class="title">Module <code>codeflare_sdk.utils.generate_yaml</code></h1>
6060from base64 import b64encode
6161from urllib3.util import parse_url
6262
63- from .kube_api_helpers import _get_api_host
64-
6563
6664def read_template(template):
6765 with open(template, "r") as stream:
@@ -95,9 +93,8 @@ <h1 class="title">Module <code>codeflare_sdk.utils.generate_yaml</code></h1>
9593 return True
9694 else:
9795 return False
98- except client.ApiException as e: # pragma: no cover
99- print(f"Error detecting cluster type defaulting to Kubernetes: {e}")
100- return False
96+ except Exception as e: # pragma: no cover
97+ return _kube_api_error_handling(e)
10198
10299
103100def update_dashboard_route(route_item, cluster_name, namespace):
@@ -160,28 +157,45 @@ <h1 class="title">Module <code>codeflare_sdk.utils.generate_yaml</code></h1>
160157 raise ValueError(
161158 f"Error: 'port' is not of type int for ingress item at index {index}"
162159 )
163- if ingress_option["port"] == 8265 :
160+ if ingress_option is not None :
164161 metadata["name"] = ingress_option["ingressName"]
165162 metadata["namespace"] = namespace
166- if "annotations" not in ingress_option.keys():
163+ metadata["labels"]["ingress-owner"] = cluster_name
164+ metadata["labels"]["ingress-options"] = "true"
165+ if (
166+ "annotations" not in ingress_option.keys()
167+ or ingress_option["annotations"] is None
168+ ):
167169 del metadata["annotations"]
168170 else:
169171 metadata["annotations"] = ingress_option["annotations"]
170- if "path" not in ingress_option.keys():
172+ if (
173+ "path" not in ingress_option.keys()
174+ or ingress_option["path"] is None
175+ ):
171176 del spec["rules"][0]["http"]["paths"][0]["path"]
172177 else:
173178 spec["rules"][0]["http"]["paths"][0]["path"] = ingress_option[
174179 "path"
175180 ]
176- if "pathType" not in ingress_option.keys():
181+ if (
182+ "pathType" not in ingress_option.keys()
183+ or ingress_option["pathType"] is None
184+ ):
177185 spec["rules"][0]["http"]["paths"][0][
178186 "pathType"
179187 ] = "ImplementationSpecific"
180- if "host" not in ingress_option.keys():
188+ if (
189+ "host" not in ingress_option.keys()
190+ or ingress_option["host"] is None
191+ ):
181192 del spec["rules"][0]["host"]
182193 else:
183194 spec["rules"][0]["host"] = ingress_option["host"]
184- if "ingressClassName" not in ingress_option.keys():
195+ if (
196+ "ingressClassName" not in ingress_option.keys()
197+ or ingress_option["ingressClassName"] is None
198+ ):
185199 del spec["ingressClassName"]
186200 else:
187201 spec["ingressClassName"] = ingress_option["ingressClassName"]
@@ -192,6 +206,7 @@ <h1 class="title">Module <code>codeflare_sdk.utils.generate_yaml</code></h1>
192206 else:
193207 spec["ingressClassName"] = "nginx"
194208 metadata["name"] = gen_dashboard_ingress_name(cluster_name)
209+ metadata["labels"]["ingress-owner"] = cluster_name
195210 metadata["namespace"] = namespace
196211 spec["rules"][0]["http"]["paths"][0]["backend"]["service"][
197212 "name"
@@ -570,10 +585,6 @@ <h1 class="title">Module <code>codeflare_sdk.utils.generate_yaml</code></h1>
570585 tls_secret_name = f"{cluster_name}-proxy-tls-secret"
571586 tls_volume_name = "proxy-tls-secret"
572587 port_name = "oauth-proxy"
573- host = _get_api_host(k8_client)
574- host = host.replace(
575- "api.", f"{gen_dashboard_ingress_name(cluster_name)}-{namespace}.apps."
576- )
577588 oauth_sidecar = _create_oauth_sidecar_object(
578589 namespace,
579590 tls_mount_location,
@@ -909,10 +920,6 @@ <h2 class="section-title" id="header-functions">Functions</h2>
909920 tls_secret_name = f"{cluster_name}-proxy-tls-secret"
910921 tls_volume_name = "proxy-tls-secret"
911922 port_name = "oauth-proxy"
912- host = _get_api_host(k8_client)
913- host = host.replace(
914- "api.", f"{gen_dashboard_ingress_name(cluster_name)}-{namespace}.apps."
915- )
916923 oauth_sidecar = _create_oauth_sidecar_object(
917924 namespace,
918925 tls_mount_location,
@@ -1096,9 +1103,8 @@ <h2 class="section-title" id="header-functions">Functions</h2>
10961103 return True
10971104 else:
10981105 return False
1099- except client.ApiException as e: # pragma: no cover
1100- print(f"Error detecting cluster type defaulting to Kubernetes: {e}")
1101- return False</ code > </ pre >
1106+ except Exception as e: # pragma: no cover
1107+ return _kube_api_error_handling(e)</ code > </ pre >
11021108</ details >
11031109</ dd >
11041110< dt id ="codeflare_sdk.utils.generate_yaml.read_template "> < code class ="name flex ">
@@ -1268,28 +1274,45 @@ <h2 class="section-title" id="header-functions">Functions</h2>
12681274 raise ValueError(
12691275 f"Error: 'port' is not of type int for ingress item at index {index}"
12701276 )
1271- if ingress_option["port"] == 8265 :
1277+ if ingress_option is not None :
12721278 metadata["name"] = ingress_option["ingressName"]
12731279 metadata["namespace"] = namespace
1274- if "annotations" not in ingress_option.keys():
1280+ metadata["labels"]["ingress-owner"] = cluster_name
1281+ metadata["labels"]["ingress-options"] = "true"
1282+ if (
1283+ "annotations" not in ingress_option.keys()
1284+ or ingress_option["annotations"] is None
1285+ ):
12751286 del metadata["annotations"]
12761287 else:
12771288 metadata["annotations"] = ingress_option["annotations"]
1278- if "path" not in ingress_option.keys():
1289+ if (
1290+ "path" not in ingress_option.keys()
1291+ or ingress_option["path"] is None
1292+ ):
12791293 del spec["rules"][0]["http"]["paths"][0]["path"]
12801294 else:
12811295 spec["rules"][0]["http"]["paths"][0]["path"] = ingress_option[
12821296 "path"
12831297 ]
1284- if "pathType" not in ingress_option.keys():
1298+ if (
1299+ "pathType" not in ingress_option.keys()
1300+ or ingress_option["pathType"] is None
1301+ ):
12851302 spec["rules"][0]["http"]["paths"][0][
12861303 "pathType"
12871304 ] = "ImplementationSpecific"
1288- if "host" not in ingress_option.keys():
1305+ if (
1306+ "host" not in ingress_option.keys()
1307+ or ingress_option["host"] is None
1308+ ):
12891309 del spec["rules"][0]["host"]
12901310 else:
12911311 spec["rules"][0]["host"] = ingress_option["host"]
1292- if "ingressClassName" not in ingress_option.keys():
1312+ if (
1313+ "ingressClassName" not in ingress_option.keys()
1314+ or ingress_option["ingressClassName"] is None
1315+ ):
12931316 del spec["ingressClassName"]
12941317 else:
12951318 spec["ingressClassName"] = ingress_option["ingressClassName"]
@@ -1300,6 +1323,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
13001323 else:
13011324 spec["ingressClassName"] = "nginx"
13021325 metadata["name"] = gen_dashboard_ingress_name(cluster_name)
1326+ metadata["labels"]["ingress-owner"] = cluster_name
13031327 metadata["namespace"] = namespace
13041328 spec["rules"][0]["http"]["paths"][0]["backend"]["service"][
13051329 "name"
0 commit comments