Skip to content

Commit

Permalink
rust: sync runtime-spec and image-spec
Browse files Browse the repository at this point in the history
* `runtime-spec`
- `linux` add support for `time_offsets`
- `cpu` add `burst`
- `LinuxUidMapping` add `time`

Signed-off-by: Aditya R <[email protected]>
  • Loading branch information
flouthoc committed Apr 20, 2023
1 parent 4c2abee commit e7b7344
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/image/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
// extern crate serde_derive;
// extern crate serde_json;
//
// use generated_module::[object Object];
// use generated_module::ImageSpec;
//
// fn main() {
// let json = r#"{"answer": 42}"#;
// let model: [object Object] = serde_json::from_str(&json).unwrap();
// let model: ImageSpec = serde_json::from_str(&json).unwrap();
// }

extern crate serde_derive;
use serde::{Serialize, Deserialize};
use std::collections::HashMap;

/// OpenContainer Config Specification
Expand Down Expand Up @@ -50,6 +50,9 @@ pub struct ImageSpec {

#[derive(Serialize, Deserialize)]
pub struct Config {
#[serde(rename = "ArgsEscaped")]
pub args_escaped: Option<bool>,

#[serde(rename = "Cmd")]
pub cmd: Option<Vec<String>>,

Expand Down
48 changes: 45 additions & 3 deletions src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
// extern crate serde_derive;
// extern crate serde_json;
//
// use generated_module::[object Object];
// use generated_module::Spec;
//
// fn main() {
// let json = r#"{"answer": 42}"#;
// let model: [object Object] = serde_json::from_str(&json).unwrap();
// let model: Spec = serde_json::from_str(&json).unwrap();
// }

extern crate serde_derive;
use serde::{Serialize, Deserialize};
use std::collections::HashMap;

/// Open Container Initiative Runtime Specification Container Configuration Schema
Expand Down Expand Up @@ -218,6 +218,9 @@ pub struct Linux {
#[serde(rename = "sysctl")]
pub sysctl: Option<HashMap<String, Option<serde_json::Value>>>,

#[serde(rename = "timeOffsets")]
pub time_offsets: Option<TimeOffsets>,

#[serde(rename = "uidMappings")]
pub uid_mappings: Option<Vec<LinuxUidMapping>>,
}
Expand Down Expand Up @@ -427,6 +430,9 @@ pub struct WeightDevice {

#[derive(Serialize, Deserialize)]
pub struct PurpleCpu {
#[serde(rename = "burst")]
pub burst: Option<i64>,

#[serde(rename = "cpus")]
pub cpus: Option<String>,

Expand Down Expand Up @@ -483,6 +489,9 @@ pub struct HugepageLimit {

#[derive(Serialize, Deserialize)]
pub struct PurpleMemory {
#[serde(rename = "checkBeforeUpdate")]
pub check_before_update: Option<bool>,

#[serde(rename = "disableOOMKiller")]
pub disable_oom_killer: Option<bool>,

Expand Down Expand Up @@ -595,6 +604,33 @@ pub struct Arg {
pub value_two: Option<i64>,
}

#[derive(Serialize, Deserialize)]
pub struct TimeOffsets {
#[serde(rename = "boottime")]
pub boottime: Option<Boottime>,

#[serde(rename = "monotonic")]
pub monotonic: Option<Monotonic>,
}

#[derive(Serialize, Deserialize)]
pub struct Boottime {
#[serde(rename = "nanosecs")]
pub nanosecs: Option<i64>,

#[serde(rename = "secs")]
pub secs: Option<i64>,
}

#[derive(Serialize, Deserialize)]
pub struct Monotonic {
#[serde(rename = "nanosecs")]
pub nanosecs: Option<i64>,

#[serde(rename = "secs")]
pub secs: Option<i64>,
}

#[derive(Serialize, Deserialize)]
pub struct LinuxUidMapping {
#[serde(rename = "containerID")]
Expand Down Expand Up @@ -1026,6 +1062,9 @@ pub enum Type {
#[serde(rename = "pid")]
Pid,

#[serde(rename = "time")]
Time,

#[serde(rename = "user")]
User,

Expand Down Expand Up @@ -1157,6 +1196,9 @@ pub enum Flag {

#[serde(rename = "SECCOMP_FILTER_FLAG_TSYNC")]
SeccompFilterFlagTsync,

#[serde(rename = "SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV")]
SeccompFilterFlagWaitKillableRecv,
}

#[derive(Serialize, Deserialize)]
Expand Down

0 comments on commit e7b7344

Please sign in to comment.