@@ -60,8 +60,6 @@ <h1 class="title">Module <code>codeflare_sdk.utils.generate_yaml</code></h1>
60
60
from base64 import b64encode
61
61
from urllib3.util import parse_url
62
62
63
- from .kube_api_helpers import _get_api_host
64
-
65
63
66
64
def read_template(template):
67
65
with open(template, "r") as stream:
@@ -95,9 +93,8 @@ <h1 class="title">Module <code>codeflare_sdk.utils.generate_yaml</code></h1>
95
93
return True
96
94
else:
97
95
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)
101
98
102
99
103
100
def update_dashboard_route(route_item, cluster_name, namespace):
@@ -160,28 +157,45 @@ <h1 class="title">Module <code>codeflare_sdk.utils.generate_yaml</code></h1>
160
157
raise ValueError(
161
158
f"Error: 'port' is not of type int for ingress item at index {index}"
162
159
)
163
- if ingress_option["port"] == 8265 :
160
+ if ingress_option is not None :
164
161
metadata["name"] = ingress_option["ingressName"]
165
162
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
+ ):
167
169
del metadata["annotations"]
168
170
else:
169
171
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
+ ):
171
176
del spec["rules"][0]["http"]["paths"][0]["path"]
172
177
else:
173
178
spec["rules"][0]["http"]["paths"][0]["path"] = ingress_option[
174
179
"path"
175
180
]
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
+ ):
177
185
spec["rules"][0]["http"]["paths"][0][
178
186
"pathType"
179
187
] = "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
+ ):
181
192
del spec["rules"][0]["host"]
182
193
else:
183
194
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
+ ):
185
199
del spec["ingressClassName"]
186
200
else:
187
201
spec["ingressClassName"] = ingress_option["ingressClassName"]
@@ -192,6 +206,7 @@ <h1 class="title">Module <code>codeflare_sdk.utils.generate_yaml</code></h1>
192
206
else:
193
207
spec["ingressClassName"] = "nginx"
194
208
metadata["name"] = gen_dashboard_ingress_name(cluster_name)
209
+ metadata["labels"]["ingress-owner"] = cluster_name
195
210
metadata["namespace"] = namespace
196
211
spec["rules"][0]["http"]["paths"][0]["backend"]["service"][
197
212
"name"
@@ -570,10 +585,6 @@ <h1 class="title">Module <code>codeflare_sdk.utils.generate_yaml</code></h1>
570
585
tls_secret_name = f"{cluster_name}-proxy-tls-secret"
571
586
tls_volume_name = "proxy-tls-secret"
572
587
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
- )
577
588
oauth_sidecar = _create_oauth_sidecar_object(
578
589
namespace,
579
590
tls_mount_location,
@@ -909,10 +920,6 @@ <h2 class="section-title" id="header-functions">Functions</h2>
909
920
tls_secret_name = f"{cluster_name}-proxy-tls-secret"
910
921
tls_volume_name = "proxy-tls-secret"
911
922
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
- )
916
923
oauth_sidecar = _create_oauth_sidecar_object(
917
924
namespace,
918
925
tls_mount_location,
@@ -1096,9 +1103,8 @@ <h2 class="section-title" id="header-functions">Functions</h2>
1096
1103
return True
1097
1104
else:
1098
1105
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 >
1102
1108
</ details >
1103
1109
</ dd >
1104
1110
< 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>
1268
1274
raise ValueError(
1269
1275
f"Error: 'port' is not of type int for ingress item at index {index}"
1270
1276
)
1271
- if ingress_option["port"] == 8265 :
1277
+ if ingress_option is not None :
1272
1278
metadata["name"] = ingress_option["ingressName"]
1273
1279
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
+ ):
1275
1286
del metadata["annotations"]
1276
1287
else:
1277
1288
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
+ ):
1279
1293
del spec["rules"][0]["http"]["paths"][0]["path"]
1280
1294
else:
1281
1295
spec["rules"][0]["http"]["paths"][0]["path"] = ingress_option[
1282
1296
"path"
1283
1297
]
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
+ ):
1285
1302
spec["rules"][0]["http"]["paths"][0][
1286
1303
"pathType"
1287
1304
] = "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
+ ):
1289
1309
del spec["rules"][0]["host"]
1290
1310
else:
1291
1311
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
+ ):
1293
1316
del spec["ingressClassName"]
1294
1317
else:
1295
1318
spec["ingressClassName"] = ingress_option["ingressClassName"]
@@ -1300,6 +1323,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
1300
1323
else:
1301
1324
spec["ingressClassName"] = "nginx"
1302
1325
metadata["name"] = gen_dashboard_ingress_name(cluster_name)
1326
+ metadata["labels"]["ingress-owner"] = cluster_name
1303
1327
metadata["namespace"] = namespace
1304
1328
spec["rules"][0]["http"]["paths"][0]["backend"]["service"][
1305
1329
"name"
0 commit comments