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
7 changes: 6 additions & 1 deletion rust/boil/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
}
23 changes: 23 additions & 0 deletions rust/boil/src/cli/tools.rs
Original file line number Diff line number Diff line change
@@ -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,
}
1 change: 1 addition & 0 deletions rust/boil/src/cmd/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod build;
pub mod completions;
pub mod image;
pub mod tools;
6 changes: 6 additions & 0 deletions rust/boil/src/cmd/tools.rs
Original file line number Diff line number Diff line change
@@ -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}");
}
8 changes: 7 additions & 1 deletion rust/boil/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use clap::Parser;
use snafu::{ResultExt, Snafu};

use crate::{
cli::{Cli, Command, ImageCommand},
cli::{Cli, Command, ImageCommand, ToolsCommand},
config::Config,
};

Expand Down Expand Up @@ -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(())
Expand Down