Skip to content

Commit

Permalink
ociplex: Implement the 'features' subcommand
Browse files Browse the repository at this point in the history
The `runc features` subcommand returns a JSON formatted string listing the
supported features. It is not documented, but it was implemented here:
opencontainers/runc#3296.

Based on the code, it does not seem to take any option.

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
  • Loading branch information
c3d committed Mar 9, 2023
1 parent afe5b15 commit 947b1ee
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions crates/ociplex/src/backend/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ impl Backend for CliBackend {
self.invoke(backargs)
}

fn features(&self, _args: liboci_cli::Features) -> Result<()> {
let backargs: Vec<OsString> = vec!["features".into()];
self.invoke(backargs)
}

fn list(&self, args: liboci_cli::List) -> Result<()> {
let mut backargs = Vec::<OsString>::new();

Expand All @@ -359,11 +364,13 @@ impl Backend for CliBackend {

self.invoke(backargs)
}

fn pause(&self, args: liboci_cli::Pause) -> Result<()> {
let backargs: Vec<OsString> = vec!["pause".into(), args.container_id.into()];

self.invoke(backargs)
}

fn ps(&self, args: liboci_cli::Ps) -> Result<()> {
let mut backargs = Vec::<OsString>::new();

Expand Down
4 changes: 4 additions & 0 deletions crates/ociplex/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub trait Backend: Debug {
CommonCmd::Checkpointt(args) => self.checkpoint(args),
CommonCmd::Events(args) => self.events(args),
CommonCmd::Exec(args) => self.exec(args),
CommonCmd::Features(args) => self.features(args),
CommonCmd::List(args) => self.list(args),
CommonCmd::Pause(args) => self.pause(args),
CommonCmd::Ps(args) => self.ps(args),
Expand Down Expand Up @@ -66,6 +67,9 @@ pub trait Backend: Debug {
fn exec(&self, args: liboci_cli::Exec) -> Result<()> {
Err(anyhow!("exec subcommand unimplemented: {:?}", args))
}
fn features(&self, args: liboci_cli::Features) -> Result<()> {
Err(anyhow!("features subcommand unimplemented: {:?}", args))
}
fn list(&self, args: liboci_cli::List) -> Result<()> {
Err(anyhow!("list subcommand unimplemented: {:?}", args))
}
Expand Down
3 changes: 3 additions & 0 deletions crates/ociplex/src/backend/trivial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ impl Backend for TrivialBackend {
fn exec(&self, args: liboci_cli::Exec) -> Result<()> {
Err(anyhow!("trivial: {:?}", args))
}
fn features(&self, args: liboci_cli::Features) -> Result<()> {
Err(anyhow!("trivial: {:?}", args))
}
fn list(&self, args: liboci_cli::List) -> Result<()> {
Err(anyhow!("trivial: {:?}", args))
}
Expand Down

0 comments on commit 947b1ee

Please sign in to comment.