modernize: JSON doesn't do "omitempty" structs, so stop asking

Drop the "omitempty" tag from the "json" tag on struct members that are
themselves structs, since the JSON encoder doesn't actually do that, per
golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
Nalin Dahyabhai 2025-09-10 13:18:15 -04:00
parent 802b069799
commit 7aedebdccd
5 changed files with 23 additions and 23 deletions

View File

@ -132,8 +132,8 @@ type Builder struct {
ImageHistoryComment string `json:"history-comment,omitempty"`
// Image metadata and runtime settings, in multiple formats.
OCIv1 v1.Image `json:"ociv1,omitempty"`
Docker docker.V2Image `json:"docker,omitempty"`
OCIv1 v1.Image `json:"ociv1"`
Docker docker.V2Image `json:"docker"`
// DefaultMountsFilePath is the file path holding the mounts to be mounted in "host-path:container-path" format.
DefaultMountsFilePath string `json:"defaultMountsFilePath,omitempty"`

View File

@ -162,13 +162,13 @@ type request struct {
preservedDirectory string
Globs []string `json:",omitempty"` // used by stat, get
preservedGlobs []string
StatOptions StatOptions `json:",omitempty"`
GetOptions GetOptions `json:",omitempty"`
PutOptions PutOptions `json:",omitempty"`
MkdirOptions MkdirOptions `json:",omitempty"`
RemoveOptions RemoveOptions `json:",omitempty"`
EnsureOptions EnsureOptions `json:",omitempty"`
ConditionalRemoveOptions ConditionalRemoveOptions `json:",omitempty"`
StatOptions StatOptions
GetOptions GetOptions
PutOptions PutOptions
MkdirOptions MkdirOptions
RemoveOptions RemoveOptions
EnsureOptions EnsureOptions
ConditionalRemoveOptions ConditionalRemoveOptions
}
func (req *request) Excludes() []string {
@ -248,15 +248,15 @@ func (req *request) GIDMap() []idtools.IDMap {
// Response encodes a single response.
type response struct {
Error string `json:",omitempty"`
Stat statResponse `json:",omitempty"`
Eval evalResponse `json:",omitempty"`
Get getResponse `json:",omitempty"`
Put putResponse `json:",omitempty"`
Mkdir mkdirResponse `json:",omitempty"`
Remove removeResponse `json:",omitempty"`
Ensure ensureResponse `json:",omitempty"`
ConditionalRemove conditionalRemoveResponse `json:",omitempty"`
Error string `json:",omitempty"`
Stat statResponse
Eval evalResponse
Get getResponse
Put putResponse
Mkdir mkdirResponse
Remove removeResponse
Ensure ensureResponse
ConditionalRemove conditionalRemoveResponse
}
// statResponse encodes a response for a single Stat request.

View File

@ -124,7 +124,7 @@ type V1Compatibility struct {
Created time.Time `json:"created"`
ContainerConfig struct {
Cmd []string
} `json:"container_config,omitempty"`
} `json:"container_config"`
Author string `json:"author,omitempty"`
ThrowAway bool `json:"throwaway,omitempty"`
}
@ -143,7 +143,7 @@ type V1Image struct {
// Container is the id of the container used to commit
Container string `json:"container,omitempty"`
// ContainerConfig is the configuration of the container that is committed into the image
ContainerConfig Config `json:"container_config,omitempty"`
ContainerConfig Config `json:"container_config"`
// DockerVersion specifies the version of Docker that was used to build the image
DockerVersion string `json:"docker_version,omitempty"`
// Author is the name of the author that was specified when committing the image

View File

@ -202,7 +202,7 @@ func Merge(mergeStrategy define.SBOMMergeStrategy, inputOutputSBOM, inputSBOM, o
Dependencies []string `json:"dependencies,omitempty"`
}
type purlDocument struct {
ImageContents purlImageContents `json:"image_contents,omitempty"`
ImageContents purlImageContents `json:"image_contents"`
}
purls := []string{}
seenPurls := make(map[string]struct{})

View File

@ -880,7 +880,7 @@ func buildPost(t *testing.T, test testCase, err error, buildTool, outputString,
// FSTree holds the information we have about an image's filesystem
type FSTree struct {
Layers []Layer `json:"layers,omitempty"`
Tree FSEntry `json:"tree,omitempty"`
Tree FSEntry `json:"tree"`
}
// Layer keeps track of the digests and contents of a layer blob
@ -900,7 +900,7 @@ type FSHeader struct {
Mode int64 `json:"mode,omitempty"`
UID int `json:"uid"`
GID int `json:"gid"`
ModTime time.Time `json:"mtime,omitempty"`
ModTime time.Time `json:"mtime"`
Devmajor int64 `json:"devmajor,omitempty"`
Devminor int64 `json:"devminor,omitempty"`
Xattrs map[string]string `json:"xattrs,omitempty"`