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,
|
job: String,
|
||||||
group: String,
|
group: String,
|
||||||
task: String,
|
task: String,
|
||||||
service: String,
|
service: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Ctx {
|
impl Ctx {
|
||||||
|
@ -139,7 +139,11 @@ fn main() -> Result<ExitCode> {
|
||||||
println!("Conflict in site {}, port {:?}:", &datacenter, port);
|
println!("Conflict in site {}, port {:?}:", &datacenter, port);
|
||||||
for reg in ®s {
|
for reg in ®s {
|
||||||
println!("- in {}, job \"{}\", group \"{}\", task \"{}\", service \"{}\"",
|
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!()
|
println!()
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ pub struct Task {
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub struct Service {
|
pub struct Service {
|
||||||
pub name: String,
|
pub name: Option<String>,
|
||||||
pub tags: Vec<String>,
|
pub tags: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,9 @@ impl Task {
|
||||||
|
|
||||||
impl Service {
|
impl Service {
|
||||||
fn from_body(b: &Body) -> Result<Self, String> {
|
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") {
|
let tags = match attribute_from_body(b, "tags") {
|
||||||
Err(_) => Vec::new(),
|
Err(_) => Vec::new(),
|
||||||
Ok(tags) => tags_from_expr(&tags)?,
|
Ok(tags) => tags_from_expr(&tags)?,
|
||||||
|
|
Loading…
Reference in a new issue