Skip to content

Commit 9004f6d

Browse files
committed
generate: Don't serialize Spec.Linux as an empty JSON object
The "does the marshaled JSON look like '{}'?" check is a pretty cheap trick, but it was the easiest way I could think of for "is there anything useful in here?". Signed-off-by: W. Trevor King <wking@tremily.us>
1 parent b61b44a commit 9004f6d

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

generate/generate.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,16 @@ func (g *Generator) Spec() *rspec.Spec {
196196
func (g *Generator) Save(w io.Writer, exportOpts ExportOptions) (err error) {
197197
var data []byte
198198

199+
if g.spec.Linux != nil {
200+
buf, err := json.Marshal(g.spec.Linux)
201+
if err != nil {
202+
return err
203+
}
204+
if string(buf) == "{}" {
205+
g.spec.Linux = nil
206+
}
207+
}
208+
199209
if exportOpts.Seccomp {
200210
data, err = json.MarshalIndent(g.spec.Linux.Seccomp, "", "\t")
201211
} else {

0 commit comments

Comments
 (0)