Skip to main content

anodizer_core/
docker_detect.rs

1//! `docker` invocations needed by the CLI's `check` command.
2//!
3//! Centralised here so all `Command::new("docker")` shell-outs live inside
4//! the module-boundaries allow-list.
5
6use std::io;
7use std::process::Command;
8
9/// Run `docker buildx version` and return whether buildx is installed and
10/// reachable.
11///
12/// `Ok(true)` — `docker buildx version` ran and exited zero.
13/// `Ok(false)` — `docker` ran but the `buildx` subcommand exited non-zero
14///   (typically: docker is present but buildx plugin not installed).
15/// `Err(_)` — `docker` itself could not be spawned (binary missing,
16///   permission denied). Distinct from `Ok(false)` so callers can log the
17///   underlying `io::Error` at trace level when surfacing "docker not
18///   available" vs. "docker installed but buildx missing".
19pub fn buildx_available() -> io::Result<bool> {
20    Command::new("docker")
21        .args(["buildx", "version"])
22        .output()
23        .map(|o| o.status.success())
24}