From a3180cbf3db825718f73d7d3899e20250c728f60 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Mon, 12 May 2025 22:27:51 -0700 Subject: [PATCH] ls: make sure current builder is available in JSON output While lsBuilder has a field called Current that gets lost because the embedded struct implements custom MarshalJSON method. Signed-off-by: Tonis Tiigi --- commands/ls.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/commands/ls.go b/commands/ls.go index 8c247679d..554ee6f4c 100644 --- a/commands/ls.go +++ b/commands/ls.go @@ -213,7 +213,17 @@ type lsContext struct { } func (c *lsContext) MarshalJSON() ([]byte, error) { - return json.Marshal(c.Builder) + // can't marshal c.Builder directly because Builder type has custom MarshalJSON + dt, err := json.Marshal(c.Builder.Builder) + if err != nil { + return nil, err + } + var m map[string]any + if err := json.Unmarshal(dt, &m); err != nil { + return nil, err + } + m["Current"] = c.Builder.Current + return json.Marshal(m) } func (c *lsContext) Name() string {