types/events: use omitzero where appropriate

In these cases, omitempty doesn't really work so it is useless,
but omitzero actually works.

As a result, output of `runc events` may omit these fields if all they
contain are zeroes.

NOTE this might be a breaking change.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2025-08-13 20:14:12 -07:00
parent 26602650ad
commit b042b6d455
+6 -6
View File
@@ -75,8 +75,8 @@ type CpuUsage struct {
} }
type Cpu struct { type Cpu struct {
Usage CpuUsage `json:"usage,omitempty"` Usage CpuUsage `json:"usage,omitzero"`
Throttling Throttling `json:"throttling,omitempty"` Throttling Throttling `json:"throttling,omitzero"`
PSI *PSIStats `json:"psi,omitempty"` PSI *PSIStats `json:"psi,omitempty"`
} }
@@ -103,10 +103,10 @@ type MemoryEntry struct {
type Memory struct { type Memory struct {
Cache uint64 `json:"cache,omitempty"` Cache uint64 `json:"cache,omitempty"`
Usage MemoryEntry `json:"usage,omitempty"` Usage MemoryEntry `json:"usage,omitzero"`
Swap MemoryEntry `json:"swap,omitempty"` Swap MemoryEntry `json:"swap,omitzero"`
Kernel MemoryEntry `json:"kernel,omitempty"` Kernel MemoryEntry `json:"kernel,omitzero"`
KernelTCP MemoryEntry `json:"kernelTCP,omitempty"` KernelTCP MemoryEntry `json:"kernelTCP,omitzero"`
Raw map[string]uint64 `json:"raw,omitempty"` Raw map[string]uint64 `json:"raw,omitempty"`
PSI *PSIStats `json:"psi,omitempty"` PSI *PSIStats `json:"psi,omitempty"`
} }