Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions rust/boil/src/build/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct BuildArguments {
/// The image version being built.
#[arg(
short, long,
value_parser = parse_image_version,
value_parser = BuildArguments::parse_image_version,
default_value_t = Self::default_image_version(),
help_heading = "Image Options"
)]
Expand Down Expand Up @@ -112,15 +112,33 @@ pub struct BuildArguments {
pub strip_architecture: bool,

/// Loads the image into the local image store.
///
/// DEPRECATED: Use -- --load instead.
#[arg(long, help_heading = "Build Options")]
#[deprecated(since = "0.1.7", note = "Use -- --load instead")]
pub load: bool,

/// Dry run. This does not build the image(s) but instead prints out the bakefile.
#[arg(short, long, alias = "dry")]
pub dry_run: bool,

/// Arguments passed after '--' which are directly passed to the Docker command.
///
/// Care needs to be taken, because these arguments can override/modify the behaviour defined
/// via the generated Bakefile. A few save arguments include but are not limited to: --load,
/// --no-cache, --progress.
#[arg(raw = true)]
pub rest: Vec<String>,
}

impl BuildArguments {
fn parse_image_version(input: &str) -> Result<Version, ParseImageVersionError> {
let version = Version::from_str(input).context(ParseVersionSnafu)?;
ensure!(version.build.is_empty(), ContainsBuildMetadataSnafu);

Ok(version)
}

fn default_image_version() -> Version {
"0.0.0-dev".parse().expect("must be a valid SemVer")
}
Expand Down Expand Up @@ -151,13 +169,6 @@ pub enum ParseImageVersionError {
ContainsBuildMetadata,
}

pub fn parse_image_version(input: &str) -> Result<Version, ParseImageVersionError> {
let version = Version::from_str(input).context(ParseVersionSnafu)?;
ensure!(version.build.is_empty(), ContainsBuildMetadataSnafu);

Ok(version)
}

#[derive(Debug, PartialEq, Snafu, EnumDiscriminants)]
pub enum ParseHostPortError {
#[snafu(display("unexpected empty input"))]
Expand Down
4 changes: 3 additions & 1 deletion rust/boil/src/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub enum Error {
}

/// This is the `boil build` command handler function.
pub fn run_command(args: BuildArguments, config: Config) -> Result<(), Error> {
pub fn run_command(args: Box<BuildArguments>, config: Config) -> Result<(), Error> {
// TODO (@Techassi): Parse Dockerfile instead to build the target graph
// Validation
ensure!(
Expand Down Expand Up @@ -77,10 +77,12 @@ pub fn run_command(args: BuildArguments, config: Config) -> Result<(), Error> {
// or by building the image ourself.

// Finally invoke the docker buildx bake command
#[allow(deprecated)]
let mut child = Command::new("docker")
.arg("buildx")
.arg("bake")
.arg_if(args.load, "--load")
.args(args.rest)
.arg("--file")
.arg("-")
.stdin(Stdio::piped())
Expand Down
2 changes: 1 addition & 1 deletion rust/boil/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub enum Command {
///
/// Requires docker with the buildx extension.
#[command(alias = "some-chicken")]
Build(BuildArguments),
Build(Box<BuildArguments>),

/// Display various structured outputs in JSON format.
Show(ShowArguments),
Expand Down