-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move container-hotplug from wrapper of docker to wrapper of runc
This means: * It can now be used for other container managers, e.g. podman or k8s * We now only start the container when existing devices are attached * We no longer need to interface with docker API, and no longer have to worry about lifecycle of the pod. The options is changed from using CLI to use annotations.
- Loading branch information
Showing
14 changed files
with
364 additions
and
1,302 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,5 @@ | ||
pub mod device; | ||
pub mod symlink; | ||
|
||
use clap::{Parser, Subcommand}; | ||
|
||
pub use device::DeviceRef; | ||
pub use symlink::Symlink; | ||
|
||
#[derive(Parser)] | ||
pub struct Args { | ||
#[command(subcommand)] | ||
pub action: Action, | ||
} | ||
|
||
#[derive(Subcommand)] | ||
#[command(max_term_width = 180)] | ||
pub enum Action { | ||
/// Wraps a call to `docker run` to allow hot-plugging devices into a | ||
/// container as they are plugged | ||
Run(Run), | ||
} | ||
|
||
#[derive(clap::Args)] | ||
pub struct Run { | ||
#[arg(short = 'd', long, id = "DEVICE")] | ||
/// Root hotplug device: [[parent-of:]*]<PREFIX>:<DEVICE> {n} | ||
/// PREFIX can be: {n} | ||
/// - usb: A USB device identified as <VID>[:<PID>[:<SERIAL>]] {n} | ||
/// - syspath: A directory path in /sys/** {n} | ||
/// - devnode: A device path in /dev/** {n} | ||
/// e.g., parent-of:usb:2b3e:c310 | ||
pub root_device: DeviceRef, | ||
|
||
#[arg(short = 'l', long, id = "SYMLINK")] | ||
/// Create a symlink for a device: <PREFIX>:<DEVICE>=<PATH> {n} | ||
/// PREFIX can be: {n} | ||
/// - usb: A USB device identified as <VID>:<PID>:<INTERFACE> {n} | ||
/// e.g., usb:2b3e:c310:1=/dev/ttyACM_CW310_0 | ||
pub symlink: Vec<Symlink>, | ||
|
||
#[arg(short = 'u', long, default_value = "5", id = "CODE")] | ||
/// Exit code to return when the root device is unplugged | ||
pub root_unplugged_exit_code: u8, | ||
|
||
#[arg(trailing_var_arg = true, id = "ARGS")] | ||
/// Arguments to pass to `docker run` | ||
pub docker_args: Vec<String>, | ||
} |
Oops, something went wrong.