Skip to content

Commit

Permalink
remove Option wrapper from cfg in Instance::new
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com>
  • Loading branch information
jprendes committed Dec 19, 2024
1 parent 4422427 commit b9b69bd
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub trait Instance {
type Engine: Send + Sync + Clone;

/// Create a new instance
fn new(id: String, cfg: Option<&InstanceConfig<Self::E>>) -> Self;
fn new(id: String, cfg: &InstanceConfig) -> Self;
/// Start the instance
/// The returned value should be a unique ID (such as a PID) for the instance.
/// Nothing internally should be using this ID, but it is returned to containerd where a user may want to use it.
Expand Down
2 changes: 1 addition & 1 deletion crates/containerd-shim-wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct MyInstance {
impl Instance for MyInstance {
type Engine = ();
fn new(_id: String, _cfg: Option<&InstanceConfig<Self::Engine>>) -> Result<Self, Error> {
fn new(_id: String, _cfg: &InstanceConfig) -> Result<Self, Error> {
todo!();
}
fn start(&self) -> Result<u32, Error> {
Expand Down
2 changes: 1 addition & 1 deletion crates/containerd-shim-wasm/src/sandbox/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub trait Instance: 'static {
type Engine: Send + Sync + Clone;

/// Create a new instance
fn new(id: String, cfg: Option<&InstanceConfig>) -> Result<Self, Error>
fn new(id: String, cfg: &InstanceConfig) -> Result<Self, Error>
where
Self: Sized;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl<T: Instance> InstanceData<T> {
#[cfg_attr(feature = "tracing", tracing::instrument(parent = tracing::Span::current(), skip_all, level = "Info"))]
pub fn new(id: impl AsRef<str>, cfg: InstanceConfig) -> Result<Self> {
let id = id.as_ref().to_string();
let instance = T::new(id, Some(&cfg))?;
let instance = T::new(id, &cfg)?;
Ok(Self {
instance,
cfg,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct InstanceStub {

impl Instance for InstanceStub {
type Engine = ();
fn new(_id: String, _cfg: Option<&InstanceConfig>) -> Result<Self, Error> {
fn new(_id: String, _cfg: &InstanceConfig) -> Result<Self, Error> {
Ok(InstanceStub {
exit_code: WaitableCell::new(),
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ impl<E: Engine + Default> SandboxInstance for Instance<E> {
type Engine = E;

#[cfg_attr(feature = "tracing", tracing::instrument(parent = tracing::Span::current(), skip_all, level = "Info"))]
fn new(id: String, cfg: Option<&InstanceConfig>) -> Result<Self, SandboxError> {
let cfg = cfg.context("missing configuration")?;
fn new(id: String, cfg: &InstanceConfig) -> Result<Self, SandboxError> {
let engine = Self::Engine::default();
let bundle = cfg.get_bundle().to_path_buf();
let namespace = cfg.get_namespace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct Instance<E: Engine>(PhantomData<E>);
impl<E: Engine> SandboxInstance for Instance<E> {
type Engine = E;

fn new(_id: String, _cfg: Option<&InstanceConfig<Self::Engine>>) -> Result<Self, SandboxError> {
fn new(_id: String, _cfg: &InstanceConfig) -> Result<Self, SandboxError> {
todo!();
}

Expand Down
2 changes: 1 addition & 1 deletion crates/containerd-shim-wasm/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ where
.set_stderr(dir.join("stderr"))
.set_stdin(dir.join("stdin"));

let instance = WasiInstance::new(self.container_name, Some(&cfg))?;
let instance = WasiInstance::new(self.container_name, &cfg)?;
Ok(WasiTest { instance, tempdir })
}
}
Expand Down

0 comments on commit b9b69bd

Please sign in to comment.