Skip to content

Commit 590acde

Browse files
authored
fix(vm): collapse nested if blocks in container engine connect (#1406)
Clippy's collapsible_if lint fails `mise run rust:lint` on main because of the nested `if let Ok(..) { if ping().is_ok() { .. } }` pattern in `connect_local_container_engine`. Introduced by 44e843e ("feat(vm): fall back to Podman socket when Docker is unavailable", #1370). Rewrite both blocks using `&&` let-chains.
1 parent c94cddb commit 590acde

1 file changed

Lines changed: 13 additions & 15 deletions

File tree

crates/openshell-driver-vm/src/driver.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,25 +1522,23 @@ fn parse_registry_reference(image_ref: &str) -> Result<Reference, Status> {
15221522
/// `DOCKER_HOST`). If Docker is unavailable, falls back to the Podman
15231523
/// socket, which exposes a Docker-compatible API.
15241524
async fn connect_local_container_engine() -> Option<Docker> {
1525-
if let Ok(docker) = Docker::connect_with_local_defaults() {
1526-
if docker.ping().await.is_ok() {
1527-
return Some(docker);
1528-
}
1525+
if let Ok(docker) = Docker::connect_with_local_defaults()
1526+
&& docker.ping().await.is_ok()
1527+
{
1528+
return Some(docker);
15291529
}
15301530

15311531
let podman_socket = podman_socket_path();
1532-
if podman_socket.exists() {
1533-
if let Ok(docker) =
1532+
if podman_socket.exists()
1533+
&& let Ok(docker) =
15341534
Docker::connect_with_unix(podman_socket.to_str()?, 120, bollard::API_DEFAULT_VERSION)
1535-
{
1536-
if docker.ping().await.is_ok() {
1537-
info!(
1538-
socket = %podman_socket.display(),
1539-
"vm driver: connected to Podman (Docker-compatible API)"
1540-
);
1541-
return Some(docker);
1542-
}
1543-
}
1535+
&& docker.ping().await.is_ok()
1536+
{
1537+
info!(
1538+
socket = %podman_socket.display(),
1539+
"vm driver: connected to Podman (Docker-compatible API)"
1540+
);
1541+
return Some(docker);
15441542
}
15451543

15461544
None

0 commit comments

Comments
 (0)