diff --git a/cli/command/checkpoint/formatter.go b/cli/command/checkpoint/formatter.go index 10706343a5..05f32d4910 100644 --- a/cli/command/checkpoint/formatter.go +++ b/cli/command/checkpoint/formatter.go @@ -34,15 +34,21 @@ func FormatWrite(fmtCtx formatter.Context, checkpoints []checkpoint.Summary) err // formatWrite writes formatted checkpoints using the Context func formatWrite(fmtCtx formatter.Context, checkpoints []checkpoint.Summary) error { - render := func(format func(subContext formatter.SubContext) error) error { + cpContext := &checkpointContext{ + HeaderContext: formatter.HeaderContext{ + Header: formatter.SubHeaderContext{ + "Name": checkpointNameHeader, + }, + }, + } + return fmtCtx.Write(cpContext, func(format func(subContext formatter.SubContext) error) error { for _, cp := range checkpoints { if err := format(&checkpointContext{c: cp}); err != nil { return err } } return nil - } - return fmtCtx.Write(newCheckpointContext(), render) + }) } type checkpointContext struct { @@ -50,14 +56,6 @@ type checkpointContext struct { c checkpoint.Summary } -func newCheckpointContext() *checkpointContext { - cpCtx := checkpointContext{} - cpCtx.Header = formatter.SubHeaderContext{ - "Name": checkpointNameHeader, - } - return &cpCtx -} - func (c *checkpointContext) MarshalJSON() ([]byte, error) { return formatter.MarshalJSON(c) }