module

Krikri::PluginHelpers::DockerCliProbe

DockerCliProbe - real community.docker's CLI-client modules (docker_image_build, docker_compose_v2) construct a DockerCLIClient BEFORE any module logic runs, and that constructor's first act is docker version --format '{{ json . }}' through run_command(check_rc=True) (module_utils/common_cli.py). A daemon that cannot be reached therefore fails those modules at this probe with the CLI's own stderr as the message - NOT the Python SDK's "Error connecting: ..." wording the API-client modules use - plus the run_command failure shape (cmd/rc/stdout/stderr + _lines).

Reproduced here so both plugins run the same probe first: resolve the docker CLI (get_bin_path('docker') - the CLI-process PATH, not the controller's), then the probe with the CLI-client's common args (--host <docker_host> whenever a docker_host is in play, DEFAULT 'unix:///var/run/docker.sock' otherwise - real passes it unconditionally unless cli_context: was given).

Constants

DEFAULT_HOST = "unix:///var/run/docker.sock"

The daemon URL common_cli.py falls back to when neither a docker_host nor a cli_context is in play (DEFAULT_DOCKER_HOST).

Class methods

base_args(docker_cli : String | Nil, docker_host : String | Nil, cli_context : String | Nil) : Array(String)

The argv prefix real's DockerCLIClient builds once in common_cli.py (self._cli_base) and prepends to EVERY CLI call it makes: the docker_cli param (or the plain docker name - #probe has already proved it resolves when it runs first), then --host <docker_host> unless a cli_context: is in play (real's own rule: no docker_host and no cli_context means the default daemon URL, still passed explicitly).

Source
base_command(docker_cli : String | Nil, docker_host : String | Nil, cli_context : String | Nil) : String

#base_args rendered for embedding in a shell command string (shlex.quote semantics - bare when safe, matching how real's _compose_cmd_str/_clean_args render the same argv).

Source
buildx_check(run : Runner, cli : String, docker_host : String | Nil, cli_context : String | Nil) : Failure | Nil

Real's buildx-plugin gate (docker_image_build.py's ImageBuilder.init): get_client_plugin_info('buildx') runs docker info --format '{{ json . }}' (call_cli_json, check_rc=True) and scans ClientInfo.Plugins for Name == 'buildx'

  • BEFORE any path/tag validation and before any Engine-API use. A host whose docker CLI has no buildx plugin (e.g. docker.io's package without docker-buildx installed) fails right here with "Docker CLI <cli> does not have the buildx plugin installed" (cli = get_cli(): the docker_cli param, else the resolved PATH entry), a plain fail_json shape. The other failure arms real can reach first, same mechanisms as the version probe:
  • non-zero rc: run_command(check_rc=True)'s shape (msg = stderr);
  • unparseable stdout: call_cli_json's own fail_json("Error while parsing JSON output of <cmd>: <exc>\nJSON output: ...\n\nError output:\n<stderr>", cmd=..., rc=..., stdout=..., stderr=...) - kwargs lead, so the same key shape as the run_command failure (the exception text is Python simplejson's, not Crystal's);
  • ClientInfo absent/not a dict: "Cannot determine Docker client information. Are you maybe using podman instead of docker?". The plugin-version comparisons real does next (LooseVersion vs 0.6.0 for secrets of type=env/value, vs 0.13.0 for more than one output) never fire here: secrets/outputs are rejected by the plugin's unsupported-parameters validation before this runs.
Source
probe(run : Runner, docker_cli : String | Nil, docker_host : String | Nil, cli_context : String | Nil = nil) : Result

Runs the probe through run (the plugin's remote_exec). Returns a Result whose #failure is nil when the daemon answered, otherwise the Failure to fail the task with.

Source
shlex_quote(value : String) : String

Python shlex.quote's split-quoting: bare when the value only contains shlex's safe characters, single-quoted otherwise - the same quoting real's _clean_args applies when it renders the cmd string into the failure result (observed: '{{ json . }}' quoted, paths and --host values bare).

Source

Nested types