set_status: consolidate whoami into get_agent_meta with optional name
This commit is contained in:
parent
77fdaf0d1e
commit
73871f18c3
10 changed files with 114 additions and 200 deletions
|
|
@ -220,16 +220,6 @@ async fn dispatch(req: &AgentRequest, agent: &str, coord: &Arc<Coordinator>) ->
|
|||
},
|
||||
}
|
||||
}
|
||||
AgentRequest::Whoami => {
|
||||
let (status_text, status_set_at) = crate::container_view::read_agent_status(agent);
|
||||
AgentResponse::Whoami {
|
||||
name: agent.to_owned(),
|
||||
role: "agent".to_owned(),
|
||||
hyperhive_rev: crate::auto_update::current_flake_rev(&coord.hyperhive_flake),
|
||||
status_text,
|
||||
status_set_at,
|
||||
}
|
||||
}
|
||||
AgentRequest::SetStatus { text } => {
|
||||
let path = crate::coordinator::Coordinator::agent_notes_dir(agent)
|
||||
.join("hyperhive-status");
|
||||
|
|
@ -255,10 +245,19 @@ async fn dispatch(req: &AgentRequest, agent: &str, coord: &Arc<Coordinator>) ->
|
|||
}
|
||||
}
|
||||
AgentRequest::GetAgentMeta { name } => {
|
||||
let target = name.as_deref().unwrap_or(agent);
|
||||
let (status_text, status_set_at) =
|
||||
crate::container_view::read_agent_status(name);
|
||||
crate::container_view::read_agent_status(target);
|
||||
let role = if target == hive_sh4re::MANAGER_AGENT {
|
||||
"manager"
|
||||
} else {
|
||||
"agent"
|
||||
}
|
||||
.to_owned();
|
||||
AgentResponse::AgentMeta {
|
||||
name: name.clone(),
|
||||
name: target.to_owned(),
|
||||
role,
|
||||
hyperhive_rev: crate::auto_update::current_flake_rev(&coord.hyperhive_flake),
|
||||
status_text,
|
||||
status_set_at,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue