Skip to content

Commit bb2ed91

Browse files
authored
Merge pull request #6343 from thaJeztah/28.x_backport_deprecate_builder_NewPruneCommand
[28.x backport] cli/command/builder: deprecate NewPruneCommand
2 parents 0bbdda8 + 1415080 commit bb2ed91

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

cli/command/builder/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func newBuilderCommand(dockerCLI command.Cli) *cobra.Command {
2424
Annotations: map[string]string{"version": "1.31"},
2525
}
2626
cmd.AddCommand(
27-
NewPruneCommand(dockerCLI),
27+
newPruneCommand(dockerCLI),
2828
// we should have a mechanism for registering sub-commands in the cli/internal/commands.Register function.
2929
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
3030
image.NewBuildCommand(dockerCLI),

cli/command/builder/prune.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,29 @@ type pruneOptions struct {
2424
}
2525

2626
// NewPruneCommand returns a new cobra prune command for images
27+
//
28+
// Deprecated: Do not import commands directly. They will be removed in a future release.
2729
func NewPruneCommand(dockerCli command.Cli) *cobra.Command {
30+
return newPruneCommand(dockerCli)
31+
}
32+
33+
// newPruneCommand returns a new cobra prune command for images
34+
func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
2835
options := pruneOptions{filter: opts.NewFilterOpt()}
2936

3037
cmd := &cobra.Command{
3138
Use: "prune",
3239
Short: "Remove build cache",
3340
Args: cli.NoArgs,
3441
RunE: func(cmd *cobra.Command, args []string) error {
35-
spaceReclaimed, output, err := runPrune(cmd.Context(), dockerCli, options)
42+
spaceReclaimed, output, err := runPrune(cmd.Context(), dockerCLI, options)
3643
if err != nil {
3744
return err
3845
}
3946
if output != "" {
40-
fmt.Fprintln(dockerCli.Out(), output)
47+
_, _ = fmt.Fprintln(dockerCLI.Out(), output)
4148
}
42-
fmt.Fprintln(dockerCli.Out(), "Total reclaimed space:", units.HumanSize(float64(spaceReclaimed)))
49+
_, _ = fmt.Fprintln(dockerCLI.Out(), "Total reclaimed space:", units.HumanSize(float64(spaceReclaimed)))
4350
return nil
4451
},
4552
Annotations: map[string]string{"version": "1.39"},

cli/command/builder/prune_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestBuilderPromptTermination(t *testing.T) {
1919
return nil, errors.New("fakeClient builderPruneFunc should not be called")
2020
},
2121
})
22-
cmd := NewPruneCommand(cli)
22+
cmd := newPruneCommand(cli)
2323
cmd.SetOut(io.Discard)
2424
cmd.SetErr(io.Discard)
2525
test.TerminatePrompt(ctx, t, cmd, cli)

0 commit comments

Comments
 (0)