Skip to content

Commit

Permalink
genpolicy: add --version flag
Browse files Browse the repository at this point in the history
Add a --version flag to the genpolicy tool that prints the current
version

Signed-off-by: Saul Paredes <[email protected]>
  • Loading branch information
Redent0r committed Apr 15, 2024
1 parent 9b7dcc0 commit ffc72e5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/tools/genpolicy/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/tools/genpolicy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[package]
name = "genpolicy"
version = "0.1.0"
version = "3.2.0-1"
authors = ["The Kata Containers community <[email protected]>"]
edition = "2021"

Expand Down
5 changes: 5 additions & 0 deletions src/tools/genpolicy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ async fn main() {
env_logger::init();
let config = utils::Config::new();

if config.version {
println!("{}", env!("CARGO_PKG_VERSION"));
return;
}

debug!("Creating policy from yaml, settings, and rules.rego files...");
let mut policy = policy::AgentPolicy::from_files(&config).await.unwrap();

Expand Down
5 changes: 5 additions & 0 deletions src/tools/genpolicy/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ struct CommandLineOptions {
require_equals= true
)]
containerd_socket_path: Option<String>,

#[clap(short, long, help = "Print version information and exit")]
version: bool,
}

/// Application configuration, derived from on command line parameters.
Expand All @@ -91,6 +94,7 @@ pub struct Config {
pub raw_out: bool,
pub base64_out: bool,
pub containerd_socket_path: Option<String>,
pub version: bool,
}

impl Config {
Expand Down Expand Up @@ -118,6 +122,7 @@ impl Config {
raw_out: args.raw_out,
base64_out: args.base64_out,
containerd_socket_path: args.containerd_socket_path,
version: args.version,
}
}
}

0 comments on commit ffc72e5

Please sign in to comment.