lightshuttle_manifest/model/command.rs
1//! Command override for container and dockerfile resources.
2//!
3//! [`Command`] is used in the `command` field of [`crate::ContainerConfig`] and
4//! [`crate::DockerfileConfig`] to override the image default `CMD`.
5
6use schemars::JsonSchema;
7use serde::{Deserialize, Serialize};
8
9/// Override for the image default `CMD`.
10///
11/// Two forms are accepted in the manifest YAML:
12///
13/// - A single string is interpreted shell-style, equivalent to wrapping
14/// the value in `sh -c "..."`. Convenient for one-liners.
15/// - An array of strings is passed directly to the container runtime as
16/// an argument vector, giving precise control over quoting and
17/// whitespace.
18///
19/// Either form becomes the container `Cmd`. The image `ENTRYPOINT` is
20/// preserved: it is never overridden, so an image declaring
21/// `ENTRYPOINT ["/usr/local/bin/app"]` runs that binary with this value
22/// appended as its arguments. Against such an image, a startup shim
23/// written as `sh -c "..."` is not executed as a command of its own; it
24/// reaches the entrypoint binary as positional arguments, which most
25/// argument parsers reject. Only images whose entrypoint is a shell, or
26/// which declare no entrypoint at all, run this value directly.
27///
28/// Used in the `command` field of [`crate::ContainerConfig`] and
29/// [`crate::DockerfileConfig`].
30#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
31#[serde(untagged)]
32pub enum Command {
33 /// Shell-style one-liner, e.g. `"./start.sh --port 8080"`.
34 Single(String),
35
36 /// Explicit argument vector, e.g. `["./start.sh", "--port", "8080"]`.
37 Args(Vec<String>),
38}