Skip to content

Commit

Permalink
Merge pull request #127 from jsturtevant/windows-layer-folders
Browse files Browse the repository at this point in the history
Do not panic if windows.layerFolder is null
  • Loading branch information
utam0k authored Apr 30, 2023
2 parents a46cd8b + b8ca149 commit 2608fc6
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/runtime/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,11 @@ fn test_load_sample_spec() {
let err = Spec::load(fixture_path);
assert!(err.is_ok(), "failed to load spec: {err:?}");
}

#[test]
fn test_load_sample_windows_spec() {
let fixture_path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("src/runtime/test/fixture/sample_windows.json");
let err = Spec::load(fixture_path);
assert!(err.is_ok(), "failed to load spec: {err:?}");
}
43 changes: 43 additions & 0 deletions src/runtime/test/fixture/sample_windows.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"ociVersion": "0.5.0-dev",
"process": {
"terminal": true,
"user": {
"uid": 1,
"gid": 1,
"username": "ContainerUser"
},
"args": [
"cmd"
],
"env": [
"PATH=C:\\Windows\\system32;C:\\Windows;"
],
"cwd": "C:\\"
},
"root": {
"path": ""
},
"hostname": "slartibartfast",
"mounts": [
],
"hooks": {
},
"linux": {
},
"windows": {
"layerFolders": null,
"resources": {
"cpu": {
"shares": 2
}
},
"network": {
"networkNamespace": "1124faf5-e1d3-43fe-b758-8e99e5b7fa02"
}
},
"annotations": {
"com.example.key1": "value1",
"com.example.key2": "value2"
}
}
3 changes: 2 additions & 1 deletion src/runtime/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ use std::collections::HashMap;
/// Windows defines the runtime configuration for Windows based containers,
/// including Hyper-V containers.
pub struct Windows {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[getset(get = "pub", set = "pub")]
/// LayerFolders contains a list of absolute paths to directories
/// containing image layers.
layer_folders: Vec<String>,
layer_folders: Option<Vec<String>>,

#[serde(default, skip_serializing_if = "Option::is_none")]
#[getset(get = "pub", set = "pub")]
Expand Down

0 comments on commit 2608fc6

Please sign in to comment.