style: apply cargo fmt workspace-wide

Pure formatting pass from `cargo fmt --all`. No logic changes. Separating
this out so the 1.9 release feature commits that follow show only their
intentional edits.
This commit is contained in:
2026-04-07 18:44:21 +01:00
parent 3915bcc1ec
commit 02a574b24e
102 changed files with 2467 additions and 1307 deletions

View File

@@ -1,10 +1,10 @@
use futures::io::AsyncBufReadExt;
use futures::StreamExt;
use futures::io::AsyncBufReadExt;
use k8s_openapi::api::core::v1::Pod;
use kube::api::LogParams;
use kube::{Api, Client};
use wfe_core::traits::log_sink::{LogChunk, LogSink, LogStreamType};
use wfe_core::WfeError;
use wfe_core::traits::log_sink::{LogChunk, LogSink, LogStreamType};
/// Stream logs from a pod container, optionally forwarding to a LogSink.
///
@@ -29,9 +29,7 @@ pub async fn stream_logs(
};
let stream = pods.log_stream(pod_name, &params).await.map_err(|e| {
WfeError::StepExecution(format!(
"failed to stream logs from pod '{pod_name}': {e}"
))
WfeError::StepExecution(format!("failed to stream logs from pod '{pod_name}': {e}"))
})?;
let mut stdout = String::new();

View File

@@ -16,7 +16,13 @@ pub fn namespace_name(prefix: &str, workflow_id: &str) -> String {
let sanitized: String = raw
.to_lowercase()
.chars()
.map(|c| if c.is_ascii_alphanumeric() || c == '-' { c } else { '-' })
.map(|c| {
if c.is_ascii_alphanumeric() || c == '-' {
c
} else {
'-'
}
})
.take(63)
.collect();
// Trim trailing hyphens
@@ -55,9 +61,9 @@ pub async fn ensure_namespace(
..Default::default()
};
api.create(&PostParams::default(), &ns)
.await
.map_err(|e| WfeError::StepExecution(format!("failed to create namespace '{name}': {e}")))?;
api.create(&PostParams::default(), &ns).await.map_err(|e| {
WfeError::StepExecution(format!("failed to create namespace '{name}': {e}"))
})?;
Ok(())
}
@@ -65,9 +71,9 @@ pub async fn ensure_namespace(
/// Delete a namespace and all resources within it.
pub async fn delete_namespace(client: &Client, name: &str) -> Result<(), WfeError> {
let api: Api<Namespace> = Api::all(client.clone());
api.delete(name, &Default::default())
.await
.map_err(|e| WfeError::StepExecution(format!("failed to delete namespace '{name}': {e}")))?;
api.delete(name, &Default::default()).await.map_err(|e| {
WfeError::StepExecution(format!("failed to delete namespace '{name}': {e}"))
})?;
Ok(())
}

View File

@@ -152,10 +152,12 @@ mod tests {
#[test]
fn build_output_data_json_value() {
let parsed: HashMap<String, String> =
[("count".into(), "42".into()), ("flag".into(), "true".into())]
.into_iter()
.collect();
let parsed: HashMap<String, String> = [
("count".into(), "42".into()),
("flag".into(), "true".into()),
]
.into_iter()
.collect();
let data = build_output_data("s", "", "", 0, &parsed);
// Numbers and booleans should be parsed as JSON, not strings.
assert_eq!(data["count"], 42);

View File

@@ -77,8 +77,16 @@ pub fn build_service_pod(svc: &ServiceDefinition, namespace: &str) -> Pod {
command,
args,
resources: Some(ResourceRequirements {
limits: if limits.is_empty() { None } else { Some(limits) },
requests: if requests.is_empty() { None } else { Some(requests) },
limits: if limits.is_empty() {
None
} else {
Some(limits)
},
requests: if requests.is_empty() {
None
} else {
Some(requests)
},
..Default::default()
}),
..Default::default()
@@ -230,10 +238,7 @@ mod tests {
let ports = spec.ports.as_ref().unwrap();
assert_eq!(ports.len(), 1);
assert_eq!(ports[0].port, 5432);
assert_eq!(
ports[0].target_port,
Some(IntOrString::Int(5432))
);
assert_eq!(ports[0].target_port, Some(IntOrString::Int(5432)));
}
#[test]
@@ -241,10 +246,7 @@ mod tests {
let svc = ServiceDefinition {
name: "app".into(),
image: "myapp".into(),
ports: vec![
WfeServicePort::tcp(8080),
WfeServicePort::tcp(8443),
],
ports: vec![WfeServicePort::tcp(8080), WfeServicePort::tcp(8443)],
env: Default::default(),
readiness: None,
command: vec![],

View File

@@ -4,9 +4,9 @@ use async_trait::async_trait;
use k8s_openapi::api::core::v1::Pod;
use kube::api::PostParams;
use kube::{Api, Client};
use wfe_core::WfeError;
use wfe_core::models::service::{ServiceDefinition, ServiceEndpoint};
use wfe_core::traits::ServiceProvider;
use wfe_core::WfeError;
use crate::config::ClusterConfig;
use crate::logs::wait_for_pod_running;
@@ -77,11 +77,8 @@ impl ServiceProvider for KubernetesServiceProvider {
.map(|r| Duration::from_millis(r.timeout_ms))
.unwrap_or(Duration::from_secs(120));
match tokio::time::timeout(
timeout,
wait_for_pod_running(&self.client, &ns, &svc.name),
)
.await
match tokio::time::timeout(timeout, wait_for_pod_running(&self.client, &ns, &svc.name))
.await
{
Ok(Ok(())) => {}
Ok(Err(e)) => {

View File

@@ -6,9 +6,9 @@ use k8s_openapi::api::batch::v1::Job;
use k8s_openapi::api::core::v1::Pod;
use kube::api::{ListParams, PostParams};
use kube::{Api, Client};
use wfe_core::WfeError;
use wfe_core::models::ExecutionResult;
use wfe_core::traits::step::{StepBody, StepExecutionContext};
use wfe_core::WfeError;
use crate::cleanup::delete_job;
use crate::config::{ClusterConfig, KubernetesStepConfig};
@@ -86,13 +86,7 @@ impl StepBody for KubernetesStep {
let env_overrides = extract_workflow_env(&context.workflow.data);
// 4. Build Job manifest.
let job_manifest = build_job(
&self.config,
&step_name,
&ns,
&env_overrides,
&self.cluster,
);
let job_manifest = build_job(&self.config, &step_name, &ns, &env_overrides, &self.cluster);
let job_name = job_manifest
.metadata
.name
@@ -111,7 +105,15 @@ impl StepBody for KubernetesStep {
let result = if let Some(timeout_ms) = self.config.timeout_ms {
match tokio::time::timeout(
Duration::from_millis(timeout_ms),
self.execute_job(&client, &ns, &job_name, &step_name, definition_id, workflow_id, context),
self.execute_job(
&client,
&ns,
&job_name,
&step_name,
definition_id,
workflow_id,
context,
),
)
.await
{
@@ -125,8 +127,16 @@ impl StepBody for KubernetesStep {
}
}
} else {
self.execute_job(&client, &ns, &job_name, &step_name, definition_id, workflow_id, context)
.await
self.execute_job(
&client,
&ns,
&job_name,
&step_name,
definition_id,
workflow_id,
context,
)
.await
};
// Always attempt cleanup.
@@ -205,9 +215,7 @@ async fn wait_for_job_pod(
.list(&ListParams::default().labels(&selector))
.await
.map_err(|e| {
WfeError::StepExecution(format!(
"failed to list pods for job '{job_name}': {e}"
))
WfeError::StepExecution(format!("failed to list pods for job '{job_name}': {e}"))
})?;
if let Some(pod) = pod_list.items.first() {
@@ -236,9 +244,10 @@ async fn wait_for_job_completion(
// Poll Job status.
for _ in 0..600 {
let job = jobs.get(job_name).await.map_err(|e| {
WfeError::StepExecution(format!("failed to get job '{job_name}': {e}"))
})?;
let job = jobs
.get(job_name)
.await
.map_err(|e| WfeError::StepExecution(format!("failed to get job '{job_name}': {e}")))?;
if let Some(status) = &job.status {
if let Some(conditions) = &status.conditions {
@@ -352,9 +361,6 @@ mod tests {
let data = serde_json::json!({"config": {"nested": true}});
let env = extract_workflow_env(&data);
// Nested object serialized as JSON string.
assert_eq!(
env.get("CONFIG"),
Some(&r#"{"nested":true}"#.to_string())
);
assert_eq!(env.get("CONFIG"), Some(&r#"{"nested":true}"#.to_string()));
}
}