From db4e648261fdc31a36d8b4768e683760fdce7eea Mon Sep 17 00:00:00 2001 From: Zhang Tianyang Date: Thu, 17 Feb 2022 11:13:49 +0800 Subject: [PATCH] Simpify Config transmission mode Signed-off-by: Zhang Tianyang --- crates/runc-shim/src/main.rs | 2 +- crates/shim/examples/skeleton.rs | 2 +- crates/shim/src/lib.rs | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/runc-shim/src/main.rs b/crates/runc-shim/src/main.rs index a0a0118..5e5aae9 100644 --- a/crates/runc-shim/src/main.rs +++ b/crates/runc-shim/src/main.rs @@ -19,5 +19,5 @@ mod service; use crate::service::Service; fn main() { - containerd_shim::run::("io.containerd.runc.v2", Vec::new()) + containerd_shim::run::("io.containerd.runc.v2", None) } diff --git a/crates/shim/examples/skeleton.rs b/crates/shim/examples/skeleton.rs index e275599..4e08579 100644 --- a/crates/shim/examples/skeleton.rs +++ b/crates/shim/examples/skeleton.rs @@ -79,5 +79,5 @@ impl shim::Task for Service { } fn main() { - shim::run::("io.containerd.empty.v1", Vec::new()) + shim::run::("io.containerd.empty.v1", None) } diff --git a/crates/shim/src/lib.rs b/crates/shim/src/lib.rs index 4ef8403..07117d3 100644 --- a/crates/shim/src/lib.rs +++ b/crates/shim/src/lib.rs @@ -186,7 +186,7 @@ pub trait Shim { } /// Shim entry point that must be invoked from `main`. -pub fn run(runtime_id: &str, opts: Vec) +pub fn run(runtime_id: &str, opts:Option) where T: Shim + Send + Sync + 'static, { @@ -196,7 +196,7 @@ where } } -fn bootstrap(runtime_id: &str, opts: Vec) -> Result<()> +fn bootstrap(runtime_id: &str, opts: Option) -> Result<()> where T: Shim + Send + Sync + 'static, { @@ -208,8 +208,7 @@ where let publisher = publisher::RemotePublisher::new(&ttrpc_address)?; // Create shim instance - let mut config = Config::default(); - opts.iter().for_each(|f| f(&mut config)); + let mut config = opts.unwrap_or_else(Config::default); // Setup signals let signals = setup_signals(&config);