From fdc90caeee3cc6c4d9a9569293b2283c8bc54463 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 16 Jul 2025 13:52:04 +0200 Subject: [PATCH] cli/command/container: deprecate DiffFormatWrite It's part of the presentation logic of the cli, and only used internally. We can consider providing utilities for these, but better as part of separate packages. Signed-off-by: Sebastiaan van Stijn --- cli/command/container/diff.go | 2 +- cli/command/container/formatter_diff.go | 7 +++++++ cli/command/container/formatter_diff_test.go | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cli/command/container/diff.go b/cli/command/container/diff.go index 694df5ab35..2b90e08e0e 100644 --- a/cli/command/container/diff.go +++ b/cli/command/container/diff.go @@ -35,5 +35,5 @@ func runDiff(ctx context.Context, dockerCLI command.Cli, containerID string) err Output: dockerCLI.Out(), Format: newDiffFormat("{{.Type}} {{.Path}}"), } - return DiffFormatWrite(diffCtx, changes) + return diffFormatWrite(diffCtx, changes) } diff --git a/cli/command/container/formatter_diff.go b/cli/command/container/formatter_diff.go index 0d74e42607..32af3ed645 100644 --- a/cli/command/container/formatter_diff.go +++ b/cli/command/container/formatter_diff.go @@ -28,7 +28,14 @@ func newDiffFormat(source string) formatter.Format { } // DiffFormatWrite writes formatted diff using the Context +// +// Deprecated: this function was only used internally and will be removed in the next release. func DiffFormatWrite(fmtCtx formatter.Context, changes []container.FilesystemChange) error { + return diffFormatWrite(fmtCtx, changes) +} + +// diffFormatWrite writes formatted diff using the [formatter.Context]. +func diffFormatWrite(fmtCtx formatter.Context, changes []container.FilesystemChange) error { return fmtCtx.Write(newDiffContext(), func(format func(subContext formatter.SubContext) error) error { for _, change := range changes { if err := format(&diffContext{c: change}); err != nil { diff --git a/cli/command/container/formatter_diff_test.go b/cli/command/container/formatter_diff_test.go index 0d9ba20d33..51ff9df666 100644 --- a/cli/command/container/formatter_diff_test.go +++ b/cli/command/container/formatter_diff_test.go @@ -50,7 +50,7 @@ D: /usr/app/old_app.js t.Run(string(tc.context.Format), func(t *testing.T) { out := bytes.NewBufferString("") tc.context.Output = out - err := DiffFormatWrite(tc.context, diffs) + err := diffFormatWrite(tc.context, diffs) if err != nil { assert.Error(t, err, tc.expected) } else {