Allow services with no name
This commit is contained in:
parent
7e9cfea9e0
commit
9cb4f6c11e
2 changed files with 10 additions and 4 deletions
|
@ -45,7 +45,7 @@ struct PortRegistration {
|
|||
job: String,
|
||||
group: String,
|
||||
task: String,
|
||||
service: String,
|
||||
service: Option<String>,
|
||||
}
|
||||
|
||||
impl Ctx {
|
||||
|
@ -139,7 +139,11 @@ fn main() -> Result<ExitCode> {
|
|||
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 => "<noname>",
|
||||
Some(s) => s
|
||||
})
|
||||
}
|
||||
println!()
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ pub struct Task {
|
|||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct Service {
|
||||
pub name: String,
|
||||
pub name: Option<String>,
|
||||
pub tags: Vec<String>,
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,9 @@ impl Task {
|
|||
|
||||
impl Service {
|
||||
fn from_body(b: &Body) -> Result<Self, String> {
|
||||
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)?,
|
||||
|
|
Loading…
Reference in a new issue