Skip to content

Commit

Permalink
replce libcontainer_instance with the simplified API
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 Aug 31, 2023
1 parent 7abb5d1 commit 8d8b9e8
Show file tree
Hide file tree
Showing 12 changed files with 231 additions and 495 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
use std::path::{Path, PathBuf};

use anyhow::{ensure, Context, Result};
use oci_spec::runtime::Spec;

use crate::sandbox::{oci, Stdio};

/// Context where the container is going to run
pub struct RuntimeContext {
///
pub module: Option<String>,
pub method: String,
pub args: Vec<String>,
Expand All @@ -24,6 +29,29 @@ impl From<&Spec> for RuntimeContext {
}
}

impl RuntimeContext {
pub fn resolve_with_path(&self, file: impl AsRef<Path>) -> Result<PathBuf> {
let executable = file.as_ref();
let cwd = std::env::current_dir()?;

if executable.to_string_lossy().contains('/') {
let path = cwd.join(executable);
ensure!(path.is_file(), "file not found");
Ok(path)
} else {
self.envs
.iter()
.find(|(key, _)| key == "PATH")
.context("PATH not defined")?
.1
.split(':')
.map(|p| cwd.join(p).join(executable))
.find(|p| p.is_file())
.context("file not found")
}
}
}

fn envs_from_spec(spec: &Spec) -> Vec<(String, String)> {
spec.process()
.as_ref()
Expand Down
122 changes: 0 additions & 122 deletions crates/containerd-shim-wasm/src/libcontainer_instance/easy/engine.rs

This file was deleted.

This file was deleted.

Loading

0 comments on commit 8d8b9e8

Please sign in to comment.