master
h 74 lines 1.41 KB
Raw
1 /*++
2
3 Copyright (c) Microsoft. All rights reserved.
4
5 Module Name:
6
7 cdi_schema.h
8
9 Abstract:
10
11 Schema for Container Device Interface (CDI) specs.
12 See https://github.com/cncf-tags/container-device-interface/blob/main/SPEC.md
13
14 --*/
15
16 #pragma once
17
18 #include "JsonUtils.h"
19
20 namespace wsl::shared::cdi {
21
22 struct DeviceNode
23 {
24 std::string path;
25 std::string permissions;
26
27 NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(DeviceNode, path, permissions);
28 };
29
30 struct Mount
31 {
32 std::string hostPath;
33 std::string containerPath;
34 std::vector<std::string> options;
35
36 NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Mount, hostPath, containerPath, options);
37 };
38
39 struct Hook
40 {
41 std::string hookName;
42 std::string path;
43 std::vector<std::string> args;
44
45 NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Hook, hookName, path, args);
46 };
47
48 struct ContainerEdits
49 {
50 std::vector<DeviceNode> deviceNodes;
51 std::vector<Mount> mounts;
52 std::vector<Hook> hooks;
53
54 NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(ContainerEdits, deviceNodes, mounts, hooks);
55 };
56
57 struct Device
58 {
59 std::string name;
60 ContainerEdits containerEdits;
61
62 NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Device, name, containerEdits);
63 };
64
65 struct Spec
66 {
67 std::string cdiVersion;
68 std::string kind;
69 std::vector<Device> devices;
70
71 NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Spec, cdiVersion, kind, devices);
72 };
73
74 } // namespace wsl::shared::cdi