From b042b6d455c4e52931e46994b13efe579d37dbd5 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 13 Aug 2025 20:14:12 -0700 Subject: [PATCH] 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 --- types/events.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/types/events.go b/types/events.go index fc741d2d9..e9dc5443a 100644 --- a/types/events.go +++ b/types/events.go @@ -75,8 +75,8 @@ type CpuUsage struct { } type Cpu struct { - Usage CpuUsage `json:"usage,omitempty"` - Throttling Throttling `json:"throttling,omitempty"` + Usage CpuUsage `json:"usage,omitzero"` + Throttling Throttling `json:"throttling,omitzero"` PSI *PSIStats `json:"psi,omitempty"` } @@ -103,10 +103,10 @@ type MemoryEntry struct { type Memory struct { Cache uint64 `json:"cache,omitempty"` - Usage MemoryEntry `json:"usage,omitempty"` - Swap MemoryEntry `json:"swap,omitempty"` - Kernel MemoryEntry `json:"kernel,omitempty"` - KernelTCP MemoryEntry `json:"kernelTCP,omitempty"` + Usage MemoryEntry `json:"usage,omitzero"` + Swap MemoryEntry `json:"swap,omitzero"` + Kernel MemoryEntry `json:"kernel,omitzero"` + KernelTCP MemoryEntry `json:"kernelTCP,omitzero"` Raw map[string]uint64 `json:"raw,omitempty"` PSI *PSIStats `json:"psi,omitempty"` }