diff --git a/src/main.rs b/src/main.rs index 5194589..e206407 100644 --- a/src/main.rs +++ b/src/main.rs @@ -45,7 +45,7 @@ struct PortRegistration { job: String, group: String, task: String, - service: String, + service: Option, } impl Ctx { @@ -139,7 +139,11 @@ fn main() -> Result { println!("Conflict in site {}, port {:?}:", &datacenter, port); for reg in ®s { println!("- in {}, job \"{}\", group \"{}\", task \"{}\", service \"{}\"", - reg.file.display(), reg.job, reg.group, reg.task, reg.service) + reg.file.display(), reg.job, reg.group, reg.task, + match ®.service { + None => "", + Some(s) => s + }) } println!() } diff --git a/src/parsing.rs b/src/parsing.rs index a9a29ae..20048c7 100644 --- a/src/parsing.rs +++ b/src/parsing.rs @@ -28,7 +28,7 @@ pub struct Task { #[derive(Deserialize, Debug)] pub struct Service { - pub name: String, + pub name: Option, pub tags: Vec, } @@ -66,7 +66,9 @@ impl Task { impl Service { fn from_body(b: &Body) -> Result { - let name = string_from_expr(&attribute_from_body(b, "name")?)?; + let name = + attribute_from_body(b, "name").ok() + .map(|e| string_from_expr(&e)).transpose()?; let tags = match attribute_from_body(b, "tags") { Err(_) => Vec::new(), Ok(tags) => tags_from_expr(&tags)?,