mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 04:34:27 +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<()> {
|
fn main() -> Result<()> {
|
||||||
let args: Vec<String> = env::args().collect();
|
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" {
|
if args.len() == 2 && args[1] == "init" {
|
||||||
rustjail::container::init_child();
|
rustjail::container::init_child();
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -177,13 +190,6 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
announce(&logger);
|
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,
|
// 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.
|
// 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")));
|
let _guard = slog_scope::set_global_logger(logger.new(o!("subsystem" => "rpc")));
|
||||||
|
Loading…
Reference in New Issue
Block a user