Skip to content

Commit 16e24b3

Browse files
committed
Changed naming convention for splitted routes.
1 parent 07906b0 commit 16e24b3

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

src/main.rs

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use tracing::Instrument;
2525

2626
use crate::{
2727
err::{I2GError, I2GResult},
28-
utils::ObjectMetaI2GExt,
28+
utils::{ObjectMetaI2GExt, sanitize_hostname},
2929
value_filters::{HeadersMatchersList, MatchRule, MatcherList, QueryMatchersList},
3030
};
3131

@@ -252,9 +252,14 @@ async fn create_http_routes(
252252
);
253253
}
254254
};
255-
for (header_matchers, query_matchers) in &match_ruleset {
255+
let mut san_path = String::from("");
256+
if let Some(path) = &path.path {
257+
san_path = format!("{}-", sanitize_hostname(path));
258+
}
259+
260+
for (num, (header_matchers, query_matchers)) in match_ruleset.iter().enumerate() {
256261
rules.push(HTTPRouteRules {
257-
name: None,
262+
name: Some(format!("{}{}", san_path, num)),
258263
backend_refs: Some(
259264
[HTTPRouteRulesBackendRefs {
260265
name: svc.name.clone(),
@@ -289,22 +294,10 @@ async fn create_http_routes(
289294
if split_routes {
290295
return Ok(rules
291296
.into_iter()
292-
.map(|rule| {
297+
.enumerate()
298+
.map(|(index, rule)| {
293299
HTTPRoute::new(
294-
&format!(
295-
"{}-{}-{}",
296-
route_info.ingress_name,
297-
safe_hostname,
298-
utils::sanitize_hostname(
299-
&rule
300-
.matches
301-
.as_ref()
302-
.and_then(|m| m.first())
303-
.and_then(|mm| mm.path.as_ref())
304-
.and_then(|p| p.value.clone())
305-
.unwrap_or_else(|| "root".to_string())
306-
)
307-
),
300+
&format!("{}-{}-{}", route_info.ingress_name, safe_hostname, index),
308301
HTTPRouteSpec {
309302
hostnames: Some(vec![route_info.hostname.clone()]),
310303
parent_refs: Some(

0 commit comments

Comments
 (0)