Skip to content

Commit b554d2e

Browse files
committed
schema: Drop pointers and nulls
Maintainers feel (and I agree) that there's no point in explicitly allowing a null value when callers can simply leave the property unset [1]. This commit removes all references to "pointer" and "null" from the JSON Schema to support that decision. While optional properties may sometimes be represented as pointer types in Go [2], optional properties should be represented in JSON Schema by not including the properties in the 'required' array. [1]: #555 (comment) [2]: style.md "Optional settings should not have pointer Go types" Signed-off-by: W. Trevor King <wking@tremily.us>
1 parent c368be6 commit b554d2e

5 files changed

Lines changed: 92 additions & 299 deletions

File tree

schema/config-linux.json

Lines changed: 69 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,24 @@
66
"properties": {
77
"devices": {
88
"id": "https://opencontainers.org/schema/bundle/linux/devices",
9-
"oneOf": [
10-
{
11-
"type": "array",
12-
"items": {
13-
"$ref": "defs-linux.json#/definitions/Device"
14-
}
15-
},
16-
{
17-
"type": "null"
18-
}
19-
]
9+
"type": "array",
10+
"items": {
11+
"$ref": "defs-linux.json#/definitions/Device"
12+
}
2013
},
2114
"uidMappings": {
2215
"id": "https://opencontainers.org/schema/bundle/linux/uidMappings",
23-
"oneOf": [
24-
{
25-
"type": "array",
26-
"items": {
27-
"$ref": "defs.json#/definitions/IDMapping"
28-
}
29-
},
30-
{
31-
"type": "null"
32-
}
33-
]
16+
"type": "array",
17+
"items": {
18+
"$ref": "defs.json#/definitions/IDMapping"
19+
}
3420
},
3521
"gidMappings": {
3622
"id": "https://opencontainers.org/schema/bundle/linux/gidMappings",
37-
"oneOf": [
38-
{
39-
"type": "array",
40-
"items": {
41-
"$ref": "defs.json#/definitions/IDMapping"
42-
}
43-
},
44-
{
45-
"type": "null"
46-
}
47-
]
23+
"type": "array",
24+
"items": {
25+
"$ref": "defs.json#/definitions/IDMapping"
26+
}
4827
},
4928
"namespaces": {
5029
"id": "https://opencontainers.org/schema/bundle/linux/namespaces",
@@ -63,17 +42,10 @@
6342
"properties": {
6443
"devices": {
6544
"id": "https://opencontainers.org/schema/bundle/linux/resources/devices",
66-
"oneOf": [
67-
{
68-
"type": "array",
69-
"items": {
70-
"$ref": "defs-linux.json#/definitions/DeviceCgroup"
71-
}
72-
},
73-
{
74-
"type": "null"
75-
}
76-
]
45+
"type": "array",
46+
"items": {
47+
"$ref": "defs-linux.json#/definitions/DeviceCgroup"
48+
}
7749
},
7850
"oomScoreAdj": {
7951
"id": "https://opencontainers.org/schema/bundle/linux/resources/oomScoreAdj",
@@ -100,75 +72,45 @@
10072
"properties": {
10173
"blkioWeight": {
10274
"id": "https://opencontainers.org/schema/bundle/linux/resources/blockIO/blkioWeight",
103-
"$ref": "defs-linux.json#/definitions/blkioWeightPointer"
75+
"$ref": "defs-linux.json#/definitions/blkioWeight"
10476
},
10577
"blkioLeafWeight": {
10678
"id": "https://opencontainers.org/schema/bundle/linux/resources/blockIO/blkioLeafWeight",
107-
"$ref": "defs-linux.json#/definitions/blkioWeightPointer"
79+
"$ref": "defs-linux.json#/definitions/blkioWeight"
10880
},
10981
"blkioThrottleReadBpsDevice": {
11082
"id": "https://opencontainers.org/schema/bundle/linux/resources/blockIO/blkioThrottleReadBpsDevice",
111-
"oneOf": [
112-
{
113-
"type": "array",
114-
"items": [
115-
{
116-
"$ref": "defs-linux.json#/definitions/blockIODeviceThrottlePointer"
117-
}
118-
]
119-
},
120-
{
121-
"type": "null"
122-
}
123-
]
83+
"type": "array",
84+
"items": {
85+
"$ref": "defs-linux.json#/definitions/blockIODeviceThrottle"
86+
}
12487
},
12588
"blkioThrottleWriteBpsDevice": {
12689
"id": "https://opencontainers.org/schema/bundle/linux/resources/blockIO/blkioThrottleWriteBpsDevice",
127-
"oneOf": [
128-
{
129-
"type": "array",
130-
"items": {
131-
"$ref": "defs-linux.json#/definitions/blockIODeviceThrottlePointer"
132-
}
133-
},
134-
{
135-
"type": "null"
136-
}
137-
]
90+
"type": "array",
91+
"items": {
92+
"$ref": "defs-linux.json#/definitions/blockIODeviceThrottle"
93+
}
13894
},
13995
"blkioThrottleReadIopsDevice": {
14096
"id": "https://opencontainers.org/schema/bundle/linux/resources/blockIO/blkioThrottleReadIopsDevice",
141-
"oneOf": [
142-
{
143-
"type": "array",
144-
"items": {
145-
"$ref": "defs-linux.json#/definitions/blockIODeviceThrottlePointer"
146-
}
147-
},
148-
{
149-
"type": "null"
150-
}
151-
]
97+
"type": "array",
98+
"items": {
99+
"$ref": "defs-linux.json#/definitions/blockIODeviceThrottle"
100+
}
152101
},
153102
"blkioThrottleWriteIopsDevice": {
154103
"id": "https://opencontainers.org/schema/bundle/linux/resources/blockIO/blkioThrottleWriteIopsDevice",
155-
"oneOf": [
156-
{
157-
"type": "array",
158-
"items": {
159-
"$ref": "defs-linux.json#/definitions/blockIODeviceThrottlePointer"
160-
}
161-
},
162-
{
163-
"type": "null"
164-
}
165-
]
104+
"type": "array",
105+
"items": {
106+
"$ref": "defs-linux.json#/definitions/blockIODeviceThrottle"
107+
}
166108
},
167109
"blkioWeightDevice": {
168110
"id": "https://opencontainers.org/schema/bundle/linux/resources/blockIO/blkioWeightDevice",
169111
"type": "array",
170112
"items": {
171-
"$ref": "defs-linux.json#/definitions/blockIODeviceWeightPointer"
113+
"$ref": "defs-linux.json#/definitions/blockIODeviceWeight"
172114
}
173115
}
174116
}
@@ -187,23 +129,23 @@
187129
},
188130
"period": {
189131
"id": "https://opencontainers.org/schema/bundle/linux/resources/cpu/period",
190-
"$ref": "defs.json#/definitions/uint64Pointer"
132+
"$ref": "defs.json#/definitions/uint64"
191133
},
192134
"quota": {
193135
"id": "https://opencontainers.org/schema/bundle/linux/resources/cpu/quota",
194-
"$ref": "defs.json#/definitions/int64Pointer"
136+
"$ref": "defs.json#/definitions/int64"
195137
},
196138
"realtimePeriod": {
197139
"id": "https://opencontainers.org/schema/bundle/linux/resources/cpu/realtimePeriod",
198-
"$ref": "defs.json#/definitions/uint64Pointer"
140+
"$ref": "defs.json#/definitions/uint64"
199141
},
200142
"realtimeRuntime": {
201143
"id": "https://opencontainers.org/schema/bundle/linux/resources/cpu/realtimeRuntime",
202-
"$ref": "defs.json#/definitions/int64Pointer"
144+
"$ref": "defs.json#/definitions/int64"
203145
},
204146
"shares": {
205147
"id": "https://opencontainers.org/schema/bundle/linux/resources/cpu/shares",
206-
"$ref": "defs.json#/definitions/uint64Pointer"
148+
"$ref": "defs.json#/definitions/uint64"
207149
}
208150
}
209151
},
@@ -213,57 +155,50 @@
213155
},
214156
"hugepageLimits": {
215157
"id": "https://opencontainers.org/schema/bundle/linux/resources/hugepageLimits",
216-
"oneOf": [
217-
{
218-
"type": "array",
219-
"items": {
220-
"type": "object",
221-
"properties": {
222-
"pageSize": {
223-
"type": "string"
224-
},
225-
"limit": {
226-
"$ref": "defs.json#/definitions/int64"
227-
}
228-
},
229-
"required": [
230-
"pageSize",
231-
"limit"
232-
]
158+
"type": "array",
159+
"items": {
160+
"type": "object",
161+
"properties": {
162+
"pageSize": {
163+
"type": "string"
164+
},
165+
"limit": {
166+
"$ref": "defs.json#/definitions/int64"
233167
}
234168
},
235-
{
236-
"type": "null"
237-
}
238-
]
169+
"required": [
170+
"pageSize",
171+
"limit"
172+
]
173+
}
239174
},
240175
"memory": {
241176
"id": "https://opencontainers.org/schema/bundle/linux/resources/memory",
242177
"type": "object",
243178
"properties": {
244179
"kernel": {
245180
"id": "https://opencontainers.org/schema/bundle/linux/resources/memory/kernel",
246-
"$ref": "defs.json#/definitions/int64Pointer"
181+
"$ref": "defs.json#/definitions/int64"
247182
},
248183
"kernelTCP": {
249184
"id": "https://opencontainers.org/schema/bundle/linux/resources/memory/kernelTCP",
250-
"$ref": "defs.json#/definitions/int64Pointer"
185+
"$ref": "defs.json#/definitions/int64"
251186
},
252187
"limit": {
253188
"id": "https://opencontainers.org/schema/bundle/linux/resources/memory/limit",
254-
"$ref": "defs.json#/definitions/int64Pointer"
189+
"$ref": "defs.json#/definitions/int64"
255190
},
256191
"reservation": {
257192
"id": "https://opencontainers.org/schema/bundle/linux/resources/memory/reservation",
258-
"$ref": "defs.json#/definitions/int64Pointer"
193+
"$ref": "defs.json#/definitions/int64"
259194
},
260195
"swap": {
261196
"id": "https://opencontainers.org/schema/bundle/linux/resources/memory/swap",
262-
"$ref": "defs.json#/definitions/int64Pointer"
197+
"$ref": "defs.json#/definitions/int64"
263198
},
264199
"swappiness": {
265200
"id": "https://opencontainers.org/schema/bundle/linux/resources/memory/swappiness",
266-
"$ref": "defs.json#/definitions/uint64Pointer"
201+
"$ref": "defs.json#/definitions/uint64"
267202
}
268203
}
269204
},
@@ -277,17 +212,10 @@
277212
},
278213
"priorities": {
279214
"id": "https://opencontainers.org/schema/bundle/linux/resources/network/priorities",
280-
"oneOf": [
281-
{
282-
"type": "array",
283-
"items": {
284-
"$ref": "defs-linux.json#/definitions/NetworkInterfacePriority"
285-
}
286-
},
287-
{
288-
"type": "null"
289-
}
290-
]
215+
"type": "array",
216+
"items": {
217+
"$ref": "defs-linux.json#/definitions/NetworkInterfacePriority"
218+
}
291219
}
292220
}
293221
}
@@ -311,17 +239,10 @@
311239
},
312240
"architectures": {
313241
"id": "https://opencontainers.org/schema/bundle/linux/seccomp/architectures",
314-
"oneOf": [
315-
{
316-
"type": "array",
317-
"items": {
318-
"$ref": "defs-linux.json#/definitions/SeccompArch"
319-
}
320-
},
321-
{
322-
"type": "null"
323-
}
324-
]
242+
"type": "array",
243+
"items": {
244+
"$ref": "defs-linux.json#/definitions/SeccompArch"
245+
}
325246
},
326247
"syscalls": {
327248
"id": "https://opencontainers.org/schema/bundle/linux/seccomp/syscalls",
@@ -334,14 +255,7 @@
334255
},
335256
"sysctl": {
336257
"id": "https://opencontainers.org/schema/bundle/linux/sysctl",
337-
"oneOf": [
338-
{
339-
"$ref": "defs.json#/definitions/mapStringString"
340-
},
341-
{
342-
"type": "null"
343-
}
344-
]
258+
"$ref": "defs.json#/definitions/mapStringString"
345259
},
346260
"maskedPaths": {
347261
"id": "https://opencontainers.org/schema/bundle/linux/maskedPaths",

0 commit comments

Comments
 (0)