Skip to content

Commit 832a375

Browse files
authored
Merge pull request #6342 from thaJeztah/deprecate_builder_NewPruneCommand
cli/command/builder: deprecate NewPruneCommand
2 parents 4d4533a + 7032f59 commit 832a375

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
@@ -26,7 +26,7 @@ func newBuilderCommand(dockerCLI command.Cli) *cobra.Command {
2626
Annotations: map[string]string{"version": "1.31"},
2727
}
2828
cmd.AddCommand(
29-
NewPruneCommand(dockerCLI),
29+
newPruneCommand(dockerCLI),
3030
// we should have a mechanism for registering sub-commands in the cli/internal/commands.Register function.
3131
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
3232
image.NewBuildCommand(dockerCLI),

cli/command/builder/prune.go

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

3535
// NewPruneCommand returns a new cobra prune command for images
36+
//
37+
// Deprecated: Do not import commands directly. They will be removed in a future release.
3638
func NewPruneCommand(dockerCli command.Cli) *cobra.Command {
39+
return newPruneCommand(dockerCli)
40+
}
41+
42+
// newPruneCommand returns a new cobra prune command for images
43+
func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
3744
options := pruneOptions{filter: opts.NewFilterOpt()}
3845

3946
cmd := &cobra.Command{
4047
Use: "prune",
4148
Short: "Remove build cache",
4249
Args: cli.NoArgs,
4350
RunE: func(cmd *cobra.Command, args []string) error {
44-
spaceReclaimed, output, err := runPrune(cmd.Context(), dockerCli, options)
51+
spaceReclaimed, output, err := runPrune(cmd.Context(), dockerCLI, options)
4552
if err != nil {
4653
return err
4754
}
4855
if output != "" {
49-
fmt.Fprintln(dockerCli.Out(), output)
56+
_, _ = fmt.Fprintln(dockerCLI.Out(), output)
5057
}
51-
fmt.Fprintln(dockerCli.Out(), "Total reclaimed space:", units.HumanSize(float64(spaceReclaimed)))
58+
_, _ = fmt.Fprintln(dockerCLI.Out(), "Total reclaimed space:", units.HumanSize(float64(spaceReclaimed)))
5259
return nil
5360
},
5461
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)