mirror of
https://github.com/containers/youki
synced 2024-05-06 07:36:17 +02:00
25 lines
766 B
Rust
25 lines
766 B
Rust
use crate::commands::load_container;
|
|
use anyhow::{Context, Result};
|
|
use clap::Clap;
|
|
use std::path::PathBuf;
|
|
|
|
/// Release any resources held by the container
|
|
#[derive(Clap, Debug)]
|
|
pub struct Delete {
|
|
#[clap(forbid_empty_values = true, required = true)]
|
|
container_id: String,
|
|
/// forces deletion of the container if it is still running (using SIGKILL)
|
|
#[clap(short, long)]
|
|
force: bool,
|
|
}
|
|
|
|
impl Delete {
|
|
pub fn exec(&self, root_path: PathBuf) -> Result<()> {
|
|
log::debug!("start deleting {}", self.container_id);
|
|
let mut container = load_container(root_path, &self.container_id)?;
|
|
container
|
|
.delete(self.force)
|
|
.with_context(|| format!("failed to delete container {}", self.container_id))
|
|
}
|
|
}
|