Skip to content

Commit 818f8f4

Browse files
author
zhouhao
committed
Some omitempty usage modifications
Signed-off-by: zhouhao <[email protected]>
1 parent 6179d36 commit 818f8f4

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

specs-go/v1/config.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,34 @@ package v1
1717
// ImageConfig defines the execution parameters which should be used as a base when running a container using an image.
1818
type ImageConfig struct {
1919
// User defines the username or UID which the process in the container should run as.
20-
User string `json:"User"`
20+
User string `json:"User,omitempty"`
2121

2222
// Memory defines the memory limit.
23-
Memory int64 `json:"Memory"`
23+
Memory int64 `json:"Memory,omitempty"`
2424

2525
// MemorySwap defines the total memory usage limit (memory + swap).
26-
MemorySwap int64 `json:"MemorySwap"`
26+
MemorySwap int64 `json:"MemorySwap,omitempty"`
2727

2828
// CPUShares is the CPU shares (relative weight vs. other containers).
29-
CPUShares int64 `json:"CpuShares"`
29+
CPUShares int64 `json:"CpuShares,omitempty"`
3030

3131
// ExposedPorts a set of ports to expose from a container running this image.
32-
ExposedPorts map[string]struct{} `json:"ExposedPorts"`
32+
ExposedPorts map[string]struct{} `json:"ExposedPorts,omitempty"`
3333

3434
// Env is a list of environment variables to be used in a container.
35-
Env []string `json:"Env"`
35+
Env []string `json:"Env,omitempty"`
3636

3737
// Entrypoint defines a list of arguments to use as the command to execute when the container starts.
38-
Entrypoint []string `json:"Entrypoint"`
38+
Entrypoint []string `json:"Entrypoint,omitempty"`
3939

4040
// Cmd defines the default arguments to the entrypoint of the container.
41-
Cmd []string `json:"Cmd"`
41+
Cmd []string `json:"Cmd,omitempty"`
4242

4343
// Volumes is a set of directories which should be created as data volumes in a container running this image.
44-
Volumes map[string]struct{} `json:"Volumes"`
44+
Volumes map[string]struct{} `json:"Volumes,omitempty"`
4545

4646
// WorkingDir sets the current working directory of the entrypoint process in the container.
47-
WorkingDir string `json:"WorkingDir"`
47+
WorkingDir string `json:"WorkingDir,omitempty"`
4848
}
4949

5050
// RootFS describes a layer content addresses
@@ -59,28 +59,28 @@ type RootFS struct {
5959
// History describes the history of a layer.
6060
type History struct {
6161
// Created is the creation time.
62-
Created string `json:"created"`
62+
Created string `json:"created,omitempty"`
6363

6464
// CreatedBy is the command which created the layer.
65-
CreatedBy string `json:"created_by"`
65+
CreatedBy string `json:"created_by,omitempty"`
6666

6767
// Author is the author of the build point.
68-
Author string `json:"author"`
68+
Author string `json:"author,omitempty"`
6969

7070
// Comment is a custom message set when creating the layer.
71-
Comment string `json:"comment"`
71+
Comment string `json:"comment,omitempty"`
7272

7373
// EmptyLayer is used to mark if the history item created a filesystem diff.
74-
EmptyLayer bool `json:"empty_layer"`
74+
EmptyLayer bool `json:"empty_layer,omitempty"`
7575
}
7676

7777
// Image is the JSON structure which describes some basic information about the image.
7878
type Image struct {
7979
// Created defines an ISO-8601 formatted combined date and time at which the image was created.
80-
Created string `json:"created"`
80+
Created string `json:"created,omitempty"`
8181

8282
// Author defines the name and/or email address of the person or entity which created and is responsible for maintaining the image.
83-
Author string `json:"author"`
83+
Author string `json:"author,omitempty"`
8484

8585
// Architecture is the CPU architecture which the binaries in this image are built to run on.
8686
Architecture string `json:"architecture"`
@@ -89,11 +89,11 @@ type Image struct {
8989
OS string `json:"os"`
9090

9191
// Config defines the execution parameters which should be used as a base when running a container using the image.
92-
Config ImageConfig `json:"config"`
92+
Config ImageConfig `json:"config,omitempty"`
9393

9494
// RootFS references the layer content addresses used by the image.
9595
RootFS RootFS `json:"rootfs"`
9696

9797
// History describes the history of each layer.
98-
History []History `json:"history"`
98+
History []History `json:"history,omitempty"`
9999
}

specs-go/v1/manifest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ type Manifest struct {
2828
Layers []Descriptor `json:"layers"`
2929

3030
// Annotations contains arbitrary metadata for the manifest list.
31-
Annotations map[string]string `json:"annotations"`
31+
Annotations map[string]string `json:"annotations,omitempty"`
3232
}

specs-go/v1/manifest_list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@ type ManifestList struct {
5858
Manifests []ManifestDescriptor `json:"manifests"`
5959

6060
// Annotations contains arbitrary metadata for the manifest list.
61-
Annotations map[string]string `json:"annotations"`
61+
Annotations map[string]string `json:"annotations,omitempty"`
6262
}

specs-go/versioned.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ type Versioned struct {
2222
SchemaVersion int `json:"schemaVersion"`
2323

2424
// MediaType is the media type of this schema.
25-
MediaType string `json:"mediaType,omitempty"`
25+
MediaType string `json:"mediaType"`
2626
}

0 commit comments

Comments
 (0)