diff --git a/rust/boil/src/build/cli.rs b/rust/boil/src/build/cli.rs index ce0073594..4f33a841a 100644 --- a/rust/boil/src/build/cli.rs +++ b/rust/boil/src/build/cli.rs @@ -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" )] @@ -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, } impl BuildArguments { + fn parse_image_version(input: &str) -> Result { + 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") } @@ -151,13 +169,6 @@ pub enum ParseImageVersionError { ContainsBuildMetadata, } -pub fn parse_image_version(input: &str) -> Result { - 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"))] diff --git a/rust/boil/src/build/mod.rs b/rust/boil/src/build/mod.rs index c7e3a41f6..ea070b6f0 100644 --- a/rust/boil/src/build/mod.rs +++ b/rust/boil/src/build/mod.rs @@ -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, config: Config) -> Result<(), Error> { // TODO (@Techassi): Parse Dockerfile instead to build the target graph // Validation ensure!( @@ -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()) diff --git a/rust/boil/src/cli.rs b/rust/boil/src/cli.rs index 85323f289..7142b0210 100644 --- a/rust/boil/src/cli.rs +++ b/rust/boil/src/cli.rs @@ -27,7 +27,7 @@ pub enum Command { /// /// Requires docker with the buildx extension. #[command(alias = "some-chicken")] - Build(BuildArguments), + Build(Box), /// Display various structured outputs in JSON format. Show(ShowArguments),