Skip to content

Commit 907507e

Browse files
committed
cli/command/container: deprecate NewDiffFormat
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 d8089e7 commit 907507e

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

cli/command/container/diff.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func runDiff(ctx context.Context, dockerCLI command.Cli, containerID string) err
3333
}
3434
diffCtx := formatter.Context{
3535
Output: dockerCLI.Out(),
36-
Format: NewDiffFormat("{{.Type}} {{.Path}}"),
36+
Format: newDiffFormat("{{.Type}} {{.Path}}"),
3737
}
3838
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
@@ -13,7 +13,14 @@ const (
1313
)
1414

1515
// NewDiffFormat returns a format for use with a diff Context
16+
//
17+
// Deprecated: this function was only used internally and will be removed in the next release.
1618
func NewDiffFormat(source string) formatter.Format {
19+
return newDiffFormat(source)
20+
}
21+
22+
// newDiffFormat returns a format for use with a diff [formatter.Context].
23+
func newDiffFormat(source string) formatter.Format {
1724
if source == formatter.TableFormatKey {
1825
return defaultDiffTableFormat
1926
}

cli/command/container/formatter_diff_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@ func TestDiffContextFormatWrite(t *testing.T) {
1616
expected string
1717
}{
1818
{
19-
formatter.Context{Format: NewDiffFormat("table")},
19+
formatter.Context{Format: newDiffFormat("table")},
2020
`CHANGE TYPE PATH
2121
C /var/log/app.log
2222
A /usr/app/app.js
2323
D /usr/app/old_app.js
2424
`,
2525
},
2626
{
27-
formatter.Context{Format: NewDiffFormat("table {{.Path}}")},
27+
formatter.Context{Format: newDiffFormat("table {{.Path}}")},
2828
`PATH
2929
/var/log/app.log
3030
/usr/app/app.js
3131
/usr/app/old_app.js
3232
`,
3333
},
3434
{
35-
formatter.Context{Format: NewDiffFormat("{{.Type}}: {{.Path}}")},
35+
formatter.Context{Format: newDiffFormat("{{.Type}}: {{.Path}}")},
3636
`C: /var/log/app.log
3737
A: /usr/app/app.js
3838
D: /usr/app/old_app.js

0 commit comments

Comments
 (0)