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

Update caps and clap #438

Merged
merged 2 commits into from
Oct 27, 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
47 changes: 26 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/integration_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ version = "0.1.0"
edition = "2018"

[dependencies.clap]
version = "=3.0.0-beta.2"
version = "=3.0.0-beta.5"
default-features = false
features = ["std", "suggestions", "derive"]

[dependencies.clap_derive]
version = "=3.0.0-beta.2"
version = "=3.0.0-beta.5"
default-features = true

[dependencies]
Expand Down
7 changes: 3 additions & 4 deletions crates/integration_test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ use crate::tests::seccomp_notify::get_seccomp_notify_test;
use crate::tests::tlb::get_tlb_test;
use crate::utils::support::set_runtime_path;
use anyhow::Result;
use clap::Clap;
use clap::Parser;
use std::path::PathBuf;
use test_framework::TestManager;
use tests::cgroups;

#[derive(Clap, Debug)]
#[derive(Parser, Debug)]
#[clap(version = "0.0.1", author = "youki team")]
struct Opts {
/// path for the container runtime to be tested
Expand All @@ -22,7 +22,7 @@ struct Opts {
/// selected tests to be run, format should be
/// space separated groups, eg
/// -t group1::test1,test3 group2 group3::test5
#[clap(short, long, multiple = true, value_delimiter = " ")]
#[clap(short, long, multiple_values = true, value_delimiter = ' ')]
tests: Option<Vec<String>>,
}

Expand All @@ -43,7 +43,6 @@ fn parse_tests(tests: &[String]) -> Vec<(&str, Option<Vec<&str>>)> {

fn main() -> Result<()> {
let opts: Opts = Opts::parse();

match std::fs::canonicalize(&opts.runtime) {
// runtime path is relative or resolved correctly
Ok(path) => set_runtime_path(&path),
Expand Down
2 changes: 1 addition & 1 deletion crates/libcgroups/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ libc = { version = "0.2.105", optional = true }
[dev-dependencies]
oci-spec = { git = "https://github.com/containers/oci-spec-rs", rev = "d6fb1e91742313cd0d0085937e2d6df5d4669720", features = ["proptests"] }
quickcheck = "1"
clap = "3.0.0-beta.2"
clap = "3.0.0-beta.5"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
env_logger = "0.9"
2 changes: 1 addition & 1 deletion crates/libcontainer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ systemd_cgroups = ["systemd"]

[dependencies]
anyhow = "1.0"
caps = { git = "https://github.com/lucab/caps-rs", rev = "cb54844", features = ["serde_support"] }
caps = "0.5.3"

chrono = { version="0.4", features = ["serde"] }
crossbeam-channel = "0.5"
Expand Down
2 changes: 1 addition & 1 deletion crates/youki/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"
description = "A container runtime written in Rust"

[dependencies.clap]
version = "3.0.0-beta.2"
version = "3.0.0-beta.5"
default-features = false
features = ["std", "suggestions", "derive", "cargo"]

Expand Down
6 changes: 3 additions & 3 deletions crates/youki/src/commands/create.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//! Handles the creation of a new container
use anyhow::Result;
use clap::Clap;
use clap::Parser;
use std::path::PathBuf;

use libcontainer::{container::builder::ContainerBuilder, syscall::syscall::create_syscall};

/// Create a container
#[derive(Clap, Debug)]
#[derive(Parser, Debug)]
pub struct Create {
/// File to write pid of the container created
// note that in the end, container is just another process
Expand All @@ -22,7 +22,7 @@ pub struct Create {
#[clap(long, default_value = "0")]
preserve_fds: i32,
/// name of the container instance to be started
#[clap(required = true)]
#[clap(forbid_empty_values = true, required = true)]
pub container_id: String,
}

Expand Down
6 changes: 3 additions & 3 deletions crates/youki/src/commands/delete.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::commands::load_container;
use anyhow::{Context, Result};
use clap::Clap;
use clap::Parser;
use std::path::PathBuf;

/// Release any resources held by the container
#[derive(Clap, Debug)]
#[derive(Parser, Debug)]
pub struct Delete {
#[clap(required = true)]
#[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)]
Expand Down
6 changes: 3 additions & 3 deletions crates/youki/src/commands/events.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use clap::Clap;
use clap::Parser;
use std::path::PathBuf;

use anyhow::{Context, Result};

use crate::commands::load_container;

/// Show resource statistics for the container
#[derive(Clap, Debug)]
#[derive(Parser, Debug)]
pub struct Events {
/// Sets the stats collection interval in seconds (default: 5s)
#[clap(long, default_value = "5")]
Expand All @@ -15,7 +15,7 @@ pub struct Events {
#[clap(long)]
pub stats: bool,
/// Name of the container instance
#[clap(required = true)]
#[clap(forbid_empty_values = true, required = true)]
pub container_id: String,
}

Expand Down
6 changes: 3 additions & 3 deletions crates/youki/src/commands/exec.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use anyhow::Result;
use clap::Clap;
use clap::Parser;
use std::{error::Error, path::PathBuf};

use libcontainer::{container::builder::ContainerBuilder, syscall::syscall::create_syscall};

/// Execute a process within an existing container
#[derive(Clap, Debug)]
#[derive(Parser, Debug)]
pub struct Exec {
/// Unix socket (file) path , which will receive file descriptor of the writing end of the pseudoterminal
#[clap(long)]
Expand All @@ -31,7 +31,7 @@ pub struct Exec {
#[clap(short, long)]
pub detach: bool,
/// Identifier of the container
#[clap(required = true)]
#[clap(forbid_empty_values = true, required = true)]
pub container_id: String,
/// Command that should be executed in the container
#[clap(required = false)]
Expand Down
4 changes: 2 additions & 2 deletions crates/youki/src/commands/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
use std::{collections::HashSet, fs, path::Path};

use anyhow::Result;
use clap::Clap;
use clap::Parser;
use procfs::{CpuInfo, Meminfo};

use libcgroups::{common::CgroupSetup, v2::controller_type::ControllerType};

/// Show information about the system
#[derive(Clap, Debug)]
#[derive(Parser, Debug)]
pub struct Info {}

impl Info {
Expand Down
6 changes: 3 additions & 3 deletions crates/youki/src/commands/kill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
use std::{convert::TryInto, path::PathBuf};

use anyhow::Result;
use clap::Clap;
use clap::Parser;

use crate::commands::load_container;
use libcontainer::signal::Signal;

/// Send the specified signal to the container
#[derive(Clap, Debug)]
#[derive(Parser, Debug)]
pub struct Kill {
#[clap(required = true)]
#[clap(forbid_empty_values = true, required = true)]
container_id: String,
signal: String,
}
Expand Down
4 changes: 2 additions & 2 deletions crates/youki/src/commands/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ use std::path::PathBuf;

use anyhow::Result;
use chrono::{DateTime, Local};
use clap::Clap;
use clap::Parser;
use tabwriter::TabWriter;

use libcontainer::container::{state::State, Container};

/// List created containers
#[derive(Clap, Debug)]
#[derive(Parser, Debug)]
pub struct List {}

impl List {
Expand Down
6 changes: 3 additions & 3 deletions crates/youki/src/commands/pause.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ use crate::commands::load_container;
use std::path::PathBuf;

use anyhow::{Context, Result};
use clap::Clap;
use clap::Parser;

/// Suspend the processes within the container
#[derive(Clap, Debug)]
#[derive(Parser, Debug)]
pub struct Pause {
#[clap(required = true)]
#[clap(forbid_empty_values = true, required = true)]
pub container_id: String,
}

Expand Down
6 changes: 3 additions & 3 deletions crates/youki/src/commands/ps.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use anyhow::{bail, Context, Result};
use clap::{self, Clap};
use clap::{self, Parser};
use libcgroups;
use libcontainer::{container::Container, utils};
use std::{path::PathBuf, process::Command};

/// Display the processes inside the container
#[derive(Clap, Debug)]
#[derive(Parser, Debug)]
pub struct Ps {
/// format to display processes: table or json (default: "table")
#[clap(short, long, default_value = "table")]
format: String,
#[clap(required = true)]
#[clap(forbid_empty_values = true, required = true)]
pub container_id: String,
/// options will be passed to the ps utility
#[clap(setting = clap::ArgSettings::Last)]
Expand Down
6 changes: 3 additions & 3 deletions crates/youki/src/commands/resume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
use std::path::PathBuf;

use anyhow::{Context, Result};
use clap::Clap;
use clap::Parser;

use crate::commands::load_container;

/// Resume the processes within the container
#[derive(Clap, Debug)]
#[derive(Parser, Debug)]
pub struct Resume {
#[clap(required = true)]
#[clap(forbid_empty_values = true, required = true)]
pub container_id: String,
}

Expand Down
Loading