Skip to content

Commit c81826f

Browse files
committed
specs-go/config: Make Linux and Solaris omitempty (again)
I'd added some omitempties in 5c2193f (specs-go/config: Make Linux and Solaris omitempty, 2016-05-06, opencontainers#431), but it turns out to not have the intended effect unless the field is also a pointer type. Before this commit: $ ./ocitools generate --template <(echo '{}') $ jq . config.json { "ociVersion": "1.0.0-rc1-dev", "platform": { "os": "linux", "arch": "amd64" }, "process": { "user": { "uid": 0, "gid": 0 }, "args": [], "cwd": "/" }, "root": { "path": "rootfs" }, "hooks": {}, "linux": { "cgroupsPath": "" }, "solaris": { "cappedCPU": {}, "cappedMemory": {} } } And after this commit: $ ./ocitools generate --template <(echo '{}') $ jq . config.json { "ociVersion": "1.0.0-rc1-dev", "platform": { "os": "linux", "arch": "amd64" }, "process": { "user": { "uid": 0, "gid": 0 }, "args": [], "cwd": "/" }, "root": { "path": "rootfs" }, "hooks": {}, } The remaining useless properties are addressed by other in-flight pull requests: * 5ca74df (config: Make 'process.args' optional, 2016-06-04, opencontainers#489) * ad33f9c (config: Explicitly list 'hooks' as optional, 2016-05-06, opencontainers#427) So I've left them alone here. Signed-off-by: W. Trevor King <[email protected]>
1 parent c8fac66 commit c81826f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

specs-go/config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ type Spec struct {
2222
Annotations map[string]string `json:"annotations,omitempty"`
2323

2424
// Linux is platform specific configuration for Linux based containers.
25-
Linux Linux `json:"linux" platform:"linux,omitempty"`
25+
Linux *Linux `json:"linux" platform:"linux,omitempty"`
2626
// Solaris is platform specific configuration for Solaris containers.
27-
Solaris Solaris `json:"solaris" platform:"solaris,omitempty"`
27+
Solaris *Solaris `json:"solaris" platform:"solaris,omitempty"`
2828
}
2929

3030
// Process contains information to start a specific application inside the container.
@@ -371,9 +371,9 @@ type Solaris struct {
371371
// Specification for automatic creation of network resources for this container.
372372
Anet []Anet `json:"anet,omitempty"`
373373
// Set limit on the amount of CPU time that can be used by container.
374-
CappedCPU CappedCPU `json:"cappedCPU,omitempty"`
374+
CappedCPU *CappedCPU `json:"cappedCPU,omitempty"`
375375
// The physical and swap caps on the memory that can be used by this container.
376-
CappedMemory CappedMemory `json:"cappedMemory,omitempty"`
376+
CappedMemory *CappedMemory `json:"cappedMemory,omitempty"`
377377
}
378378

379379
// CappedCPU allows users to set limit on the amount of CPU time that can be used by container.

0 commit comments

Comments
 (0)