diff --git a/src/runtime/test.rs b/src/runtime/test.rs index d76812f380..515180af87 100644 --- a/src/runtime/test.rs +++ b/src/runtime/test.rs @@ -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:?}"); +} diff --git a/src/runtime/test/fixture/sample_windows.json b/src/runtime/test/fixture/sample_windows.json new file mode 100644 index 0000000000..fb1682cbcb --- /dev/null +++ b/src/runtime/test/fixture/sample_windows.json @@ -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" + } +} diff --git a/src/runtime/windows.rs b/src/runtime/windows.rs index 95e87d1b4e..17f80c1787 100644 --- a/src/runtime/windows.rs +++ b/src/runtime/windows.rs @@ -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, + layer_folders: Option>, #[serde(default, skip_serializing_if = "Option::is_none")] #[getset(get = "pub", set = "pub")]