Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix spec path in delete #130

Merged
merged 1 commit into from
Jul 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion oci_spec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,8 @@ pub struct Spec {
impl Spec {
pub fn load<P: AsRef<Path>>(path: P) -> Result<Self> {
let path = path.as_ref();
let file = File::open(path).with_context(|| format!("failed to open {:?}", path))?;
let file =
File::open(path).with_context(|| format!("load spec: failed to open {:?}", path))?;
let spec: Spec = serde_json::from_reader(&file)?;
Ok(spec)
}
Expand Down
7 changes: 1 addition & 6 deletions src/delete.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::fs;
use std::path::Path;
use std::path::PathBuf;

use anyhow::{bail, Result};
Expand Down Expand Up @@ -42,11 +41,7 @@ impl Delete {
log::debug!("container status: {:?}", container.status());
if container.can_delete() {
if container.root.exists() {
nix::unistd::chdir(&PathBuf::from(&container.state.bundle))?;
let config_absolute_path = &PathBuf::from(&container.state.bundle)
.join(Path::new("config.json"))
.to_string_lossy()
.to_string();
let config_absolute_path = container.root.join("config.json");
log::debug!("load spec from {:?}", config_absolute_path);
let spec = oci_spec::Spec::load(config_absolute_path)?;
log::debug!("spec: {:?}", spec);
Expand Down