Skip to content

Commit 0879a94

Browse files
arcnmxjonboulle
authored andcommitted
Appropriately mark optional fields as omitempty
Signed-off-by: Jonathan Boulle <[email protected]>
1 parent 2fd5ad6 commit 0879a94

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type Spec struct {
1313
// Root is the root information for the container's filesystem.
1414
Root Root `json:"root"`
1515
// Hostname is the container's host name.
16-
Hostname string `json:"hostname"`
16+
Hostname string `json:"hostname,omitempty"`
1717
// Mounts profile configuration for adding mounts to the container's filesystem.
1818
Mounts []MountPoint `json:"mounts"`
1919
}
@@ -27,10 +27,10 @@ type Process struct {
2727
// Args specifies the binary and arguments for the application to execute.
2828
Args []string `json:"args"`
2929
// Env populates the process environment for the process.
30-
Env []string `json:"env"`
30+
Env []string `json:"env,omitempty"`
3131
// Cwd is the current working directory for the process and must be
3232
// relative to the container's root.
33-
Cwd string `json:"cwd"`
33+
Cwd string `json:"cwd,omitempty"`
3434
}
3535

3636
// Root contains information about the container's root filesystem on the host.

config_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ type User struct {
2121
// GID is the group id.
2222
GID uint32 `json:"gid"`
2323
// AdditionalGids are additional group ids set for the container's process.
24-
AdditionalGids []uint32 `json:"additionalGids"`
24+
AdditionalGids []uint32 `json:"additionalGids,omitempty"`
2525
}

runtime_config.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ type RuntimeSpec struct {
1515
// Hook specifies a command that is run at a particular event in the lifecycle of a container
1616
type Hook struct {
1717
Path string `json:"path"`
18-
Args []string `json:"args"`
19-
Env []string `json:"env"`
18+
Args []string `json:"args,omitempty"`
19+
Env []string `json:"env,omitempty"`
2020
}
2121

2222
// Hooks for container setup and teardown
2323
type Hooks struct {
2424
// Prestart is a list of hooks to be run before the container process is executed.
2525
// On Linux, they are run after the container namespaces are created.
26-
Prestart []Hook `json:"prestart"`
26+
Prestart []Hook `json:"prestart,omitempty"`
2727
// Poststart is a list of hooks to be run after the container process is started.
28-
Poststart []Hook `json:"poststart"`
28+
Poststart []Hook `json:"poststart,omitempty"`
2929
// Poststop is a list of hooks to be run after the container process exits.
30-
Poststop []Hook `json:"poststop"`
30+
Poststop []Hook `json:"poststop,omitempty"`
3131
}
3232

3333
// Mount specifies a mount for a container
@@ -38,5 +38,5 @@ type Mount struct {
3838
// linux based systems this would be the file on the host.
3939
Source string `json:"source"`
4040
// Options are fstab style mount options.
41-
Options []string `json:"options"`
41+
Options []string `json:"options,omitempty"`
4242
}

runtime_config_linux.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ type LinuxRuntimeSpec struct {
1515
// LinuxRuntime hosts the Linux-only runtime information
1616
type LinuxRuntime struct {
1717
// UIDMapping specifies user mappings for supporting user namespaces on linux.
18-
UIDMappings []IDMapping `json:"uidMappings"`
18+
UIDMappings []IDMapping `json:"uidMappings,omitempty"`
1919
// GIDMapping specifies group mappings for supporting user namespaces on linux.
20-
GIDMappings []IDMapping `json:"gidMappings"`
20+
GIDMappings []IDMapping `json:"gidMappings,omitempty"`
2121
// Rlimits specifies rlimit options to apply to the container's process.
22-
Rlimits []Rlimit `json:"rlimits"`
22+
Rlimits []Rlimit `json:"rlimits,omitempty"`
2323
// Sysctl are a set of key value pairs that are set for the container on start
24-
Sysctl map[string]string `json:"sysctl"`
24+
Sysctl map[string]string `json:"sysctl,omitempty"`
2525
// Resources contain cgroup information for handling resource constraints
2626
// for the container
2727
Resources *Resources `json:"resources,omitempty"`
@@ -49,7 +49,7 @@ type Namespace struct {
4949
Type NamespaceType `json:"type"`
5050
// Path is a path to an existing namespace persisted on disk that can be joined
5151
// and is of the same type
52-
Path string `json:"path"`
52+
Path string `json:"path,omitempty"`
5353
}
5454

5555
// NamespaceType is one of the linux namespaces

0 commit comments

Comments
 (0)