Skip to content

Commit fdc90ca

Browse files
committed
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 <github@gone.nl>
1 parent 0db7b9f commit fdc90ca

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

‎cli/command/container/diff.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ func runDiff(ctx context.Context, dockerCLI command.Cli, containerID string) err
3535
Output: dockerCLI.Out(),
3636
Format: newDiffFormat("{{.Type}} {{.Path}}"),
3737
}
38-
return DiffFormatWrite(diffCtx, changes)
38+
return diffFormatWrite(diffCtx, changes)
3939
}

‎cli/command/container/formatter_diff.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@ func newDiffFormat(source string) formatter.Format {
2828
}
2929

3030
// DiffFormatWrite writes formatted diff using the Context
31+
//
32+
// Deprecated: this function was only used internally and will be removed in the next release.
3133
func DiffFormatWrite(fmtCtx formatter.Context, changes []container.FilesystemChange) error {
34+
return diffFormatWrite(fmtCtx, changes)
35+
}
36+
37+
// diffFormatWrite writes formatted diff using the [formatter.Context].
38+
func diffFormatWrite(fmtCtx formatter.Context, changes []container.FilesystemChange) error {
3239
return fmtCtx.Write(newDiffContext(), func(format func(subContext formatter.SubContext) error) error {
3340
for _, change := range changes {
3441
if err := format(&diffContext{c: change}); err != nil {

‎cli/command/container/formatter_diff_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ D: /usr/app/old_app.js
5050
t.Run(string(tc.context.Format), func(t *testing.T) {
5151
out := bytes.NewBufferString("")
5252
tc.context.Output = out
53-
err := DiffFormatWrite(tc.context, diffs)
53+
err := diffFormatWrite(tc.context, diffs)
5454
if err != nil {
5555
assert.Error(t, err, tc.expected)
5656
} else {

0 commit comments

Comments
 (0)