mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 04:04:45 +00:00
main: Simplify version handling
Print a simple version string rather than delaying the output to display a structured version string. The structured output is potentially more useful but: - This output is not consistent with other components. - Delaying the output makes `--version` unusable in some environments (since a lot of setup is called before the version string can be output). Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
parent
bba2773d7d
commit
e2952b5354
@ -105,6 +105,19 @@ fn announce(logger: &Logger) {
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
|
||||
if args.len() == 2 && args[1] == "--version" {
|
||||
println!(
|
||||
"{} version {} (api version: {}, commit version: {}, type: rust)",
|
||||
NAME,
|
||||
version::AGENT_VERSION,
|
||||
version::API_VERSION,
|
||||
env::var("VERSION_COMMIT").unwrap_or("unknown".to_string())
|
||||
);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if args.len() == 2 && args[1] == "init" {
|
||||
rustjail::container::init_child();
|
||||
exit(0);
|
||||
@ -177,13 +190,6 @@ fn main() -> Result<()> {
|
||||
|
||||
announce(&logger);
|
||||
|
||||
if args.len() == 2 && args[1] == "--version" {
|
||||
// force logger to flush
|
||||
drop(logger);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// This "unused" variable is required as it enables the global (and crucially static) logger,
|
||||
// which is required to satisfy the the lifetime constraints of the auto-generated gRPC code.
|
||||
let _guard = slog_scope::set_global_logger(logger.new(o!("subsystem" => "rpc")));
|
||||
|
Loading…
Reference in New Issue
Block a user