swarm-wire: take notices's wire types, fmt the moved imports
This commit is contained in:
parent
e111807f59
commit
fc72bea151
12 changed files with 72 additions and 86 deletions
|
|
@ -33,8 +33,8 @@ use std::collections::BTreeSet;
|
|||
use std::sync::Arc;
|
||||
|
||||
use anyhow::{Context, Result, bail};
|
||||
use swarm_wire::wanted::{AgentState, HiveWanted};
|
||||
use swarm_secret_client::{SecretStore, mtls, queue};
|
||||
use swarm_wire::wanted::{AgentState, HiveWanted};
|
||||
use x509_cert::der::DecodePem as _;
|
||||
|
||||
use crate::wanted::WantedWriter;
|
||||
|
|
|
|||
|
|
@ -141,10 +141,9 @@ impl AgentStatusReader {
|
|||
else {
|
||||
continue;
|
||||
};
|
||||
let payload = match serde_json::from_slice::<
|
||||
swarm_wire::agent_status::AgentStatus,
|
||||
>(&entry.value)
|
||||
{
|
||||
let payload = match serde_json::from_slice::<swarm_wire::agent_status::AgentStatus>(
|
||||
&entry.value,
|
||||
) {
|
||||
Ok(status) => serde_json::to_value(status).ok(),
|
||||
Err(e) => {
|
||||
tracing::warn!(
|
||||
|
|
|
|||
|
|
@ -78,9 +78,7 @@ pub(crate) struct AgentDeclaration {
|
|||
state: String,
|
||||
}
|
||||
|
||||
pub(crate) fn render(
|
||||
declaration: &swarm_wire::wanted::HiveWanted,
|
||||
) -> Vec<AgentDeclaration> {
|
||||
pub(crate) fn render(declaration: &swarm_wire::wanted::HiveWanted) -> Vec<AgentDeclaration> {
|
||||
declaration
|
||||
.agents
|
||||
.iter()
|
||||
|
|
@ -867,9 +865,7 @@ async fn placements_elsewhere<E, Fut>(
|
|||
read_declared: impl FnOnce() -> Fut,
|
||||
) -> Result<Vec<String>, E>
|
||||
where
|
||||
Fut: std::future::Future<
|
||||
Output = Result<Vec<(String, swarm_wire::wanted::HiveWanted)>, E>,
|
||||
>,
|
||||
Fut: std::future::Future<Output = Result<Vec<(String, swarm_wire::wanted::HiveWanted)>, E>>,
|
||||
{
|
||||
let queued = snapshot_queued();
|
||||
let declared = read_declared().await?;
|
||||
|
|
@ -886,8 +882,7 @@ async fn declarations_elsewhere(
|
|||
state: &AppState,
|
||||
agent: &str,
|
||||
hive: &str,
|
||||
) -> Result<Vec<(String, swarm_wire::wanted::HiveWanted)>, problem_details::ProblemDetails>
|
||||
{
|
||||
) -> Result<Vec<(String, swarm_wire::wanted::HiveWanted)>, problem_details::ProblemDetails> {
|
||||
read_declarations(state, state.hives.iter().filter(|h| h.name != hive))
|
||||
.await
|
||||
.map_err(|(other, e)| {
|
||||
|
|
@ -1709,10 +1704,9 @@ mod tests {
|
|||
state: swarm_wire::wanted::AgentState,
|
||||
) -> (String, swarm_wire::wanted::HiveWanted) {
|
||||
let mut declaration = swarm_wire::wanted::HiveWanted::default();
|
||||
declaration.agents.insert(
|
||||
agent.to_owned(),
|
||||
swarm_wire::wanted::AgentWanted { state },
|
||||
);
|
||||
declaration
|
||||
.agents
|
||||
.insert(agent.to_owned(), swarm_wire::wanted::AgentWanted { state });
|
||||
(hive.to_owned(), declaration)
|
||||
}
|
||||
|
||||
|
|
@ -2010,8 +2004,7 @@ mod tests {
|
|||
/// declaration before it is written, as it refuses creation.
|
||||
#[tokio::test]
|
||||
async fn set_agent_state_refuses_when_the_wanted_state_is_unreadable() {
|
||||
let err =
|
||||
set_on_disconnected_pr1ma("atlas", swarm_wire::wanted::AgentState::Up).await;
|
||||
let err = set_on_disconnected_pr1ma("atlas", swarm_wire::wanted::AgentState::Up).await;
|
||||
assert_eq!(
|
||||
err.status,
|
||||
Some(axum::http::StatusCode::SERVICE_UNAVAILABLE),
|
||||
|
|
@ -2029,8 +2022,7 @@ mod tests {
|
|||
#[tokio::test]
|
||||
async fn set_agent_state_does_not_check_a_destroy() {
|
||||
let err =
|
||||
set_on_disconnected_pr1ma("admin", swarm_wire::wanted::AgentState::Destroyed)
|
||||
.await;
|
||||
set_on_disconnected_pr1ma("admin", swarm_wire::wanted::AgentState::Destroyed).await;
|
||||
assert_eq!(
|
||||
err.status,
|
||||
Some(axum::http::StatusCode::SERVICE_UNAVAILABLE),
|
||||
|
|
|
|||
Loading…
Reference in a new issue