From c03e3959717e9fd3a31f946975884807c32fef80 Mon Sep 17 00:00:00 2001 From: Techassi Date: Fri, 21 Aug 2026 10:47:03 +0200 Subject: [PATCH] feat(boil): Add floating-tag tool --- rust/boil/src/cli/mod.rs | 7 ++++++- rust/boil/src/cli/tools.rs | 23 +++++++++++++++++++++++ rust/boil/src/cmd/mod.rs | 1 + rust/boil/src/cmd/tools.rs | 6 ++++++ rust/boil/src/main.rs | 8 +++++++- 5 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 rust/boil/src/cli/tools.rs create mode 100644 rust/boil/src/cmd/tools.rs diff --git a/rust/boil/src/cli/mod.rs b/rust/boil/src/cli/mod.rs index e10962b72..5151ab68f 100644 --- a/rust/boil/src/cli/mod.rs +++ b/rust/boil/src/cli/mod.rs @@ -3,15 +3,17 @@ use std::{path::PathBuf, sync::LazyLock}; use clap::{Parser, Subcommand}; use regex::Regex; use snafu::Snafu; +use url::Host; mod build; mod completions; mod image; +mod tools; pub use build::*; pub use completions::*; pub use image::*; -use url::Host; +pub use tools::*; // This is derived from the general rule where the length of the tag can be up to 128 chars // See: https://github.com/opencontainers/distribution-spec/blob/main/spec.md @@ -76,6 +78,9 @@ pub enum Command { /// Alias for `image list`. Images(ImageListArguments), + /// Various small tools for working with images and versions. + Tools(ToolsArguments), + /// Generate shell completions. Completions(CompletionsArguments), } diff --git a/rust/boil/src/cli/tools.rs b/rust/boil/src/cli/tools.rs new file mode 100644 index 000000000..4b8c2b134 --- /dev/null +++ b/rust/boil/src/cli/tools.rs @@ -0,0 +1,23 @@ +use clap::{Args, Parser, Subcommand}; + +#[derive(Debug, Parser)] +pub struct ToolsArguments { + #[command(subcommand)] + pub command: ToolsCommand, +} + +#[derive(Debug, Subcommand)] +pub enum ToolsCommand { + /// Turn the provided version tag into a floating tag according to boil's rules. + // + // The main user of this command is stackabletech/actions to be able to construct the floating + // tag for the image index manifest tag. This command serves as a stepping stone for a more + // robust solution using structured data output directly from boil. + FloatingTag(FloatingTagArguments), +} + +#[derive(Debug, Args)] +pub struct FloatingTagArguments { + /// The source version tag which should be converted into a floating version tag. + pub version: semver::Version, +} diff --git a/rust/boil/src/cmd/mod.rs b/rust/boil/src/cmd/mod.rs index dc1532eaa..bf11fefb0 100644 --- a/rust/boil/src/cmd/mod.rs +++ b/rust/boil/src/cmd/mod.rs @@ -1,3 +1,4 @@ pub mod build; pub mod completions; pub mod image; +pub mod tools; diff --git a/rust/boil/src/cmd/tools.rs b/rust/boil/src/cmd/tools.rs new file mode 100644 index 000000000..f400d84c4 --- /dev/null +++ b/rust/boil/src/cmd/tools.rs @@ -0,0 +1,6 @@ +use crate::{cli::FloatingTagArguments, utils::VersionExt}; + +pub fn floating_tag(args: FloatingTagArguments) { + let floating_tag = args.version.floating(); + println!("{floating_tag}"); +} diff --git a/rust/boil/src/main.rs b/rust/boil/src/main.rs index b88352307..29decd43b 100644 --- a/rust/boil/src/main.rs +++ b/rust/boil/src/main.rs @@ -2,7 +2,7 @@ use clap::Parser; use snafu::{ResultExt, Snafu}; use crate::{ - cli::{Cli, Command, ImageCommand}, + cli::{Cli, Command, ImageCommand, ToolsCommand}, config::Config, }; @@ -83,6 +83,12 @@ async fn main() -> Result<(), Error> { } }, Command::Images(arguments) => cmd::image::list_images(arguments).context(ImageSnafu), + Command::Tools(arguments) => match arguments.command { + ToolsCommand::FloatingTag(arguments) => { + cmd::tools::floating_tag(arguments); + Ok(()) + } + }, Command::Completions(arguments) => { cmd::completions::run_command(arguments); Ok(())