Skip to content

Commit c0f78d4

Browse files
committed
Unexport the builder command and bake stub command
This patch unexports the `builder` and `bake` stub command and it adds deprecation notices on the exported functions. It also registers the commands using the new `cli/internal/commands` package when the init function executes. Signed-off-by: Alano Terblanche <[email protected]>
1 parent b6ab205 commit c0f78d4

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

cli/command/builder/cmd.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,34 @@ import (
66
"github.com/docker/cli/cli"
77
"github.com/docker/cli/cli/command"
88
"github.com/docker/cli/cli/command/image"
9+
"github.com/docker/cli/internal/commands"
910
)
1011

12+
func init() {
13+
commands.RegisterCommand(newBuilderCommand)
14+
commands.RegisterCommand(func(c command.Cli) *cobra.Command {
15+
return newBakeStubCommand(c)
16+
})
17+
}
18+
1119
// NewBuilderCommand returns a cobra command for `builder` subcommands
12-
func NewBuilderCommand(dockerCli command.Cli) *cobra.Command {
20+
//
21+
// Deprecated: Do not import commands directly. They will be removed in a future release.
22+
func NewBuilderCommand(dockerCLI command.Cli) *cobra.Command {
23+
return newBuilderCommand(dockerCLI)
24+
}
25+
26+
func newBuilderCommand(dockerCLI command.Cli) *cobra.Command {
1327
cmd := &cobra.Command{
1428
Use: "builder",
1529
Short: "Manage builds",
1630
Args: cli.NoArgs,
17-
RunE: command.ShowHelp(dockerCli.Err()),
31+
RunE: command.ShowHelp(dockerCLI.Err()),
1832
Annotations: map[string]string{"version": "1.31"},
1933
}
2034
cmd.AddCommand(
21-
NewPruneCommand(dockerCli),
22-
image.NewBuildCommand(dockerCli),
35+
NewPruneCommand(dockerCLI),
36+
image.NewBuildCommand(dockerCLI),
2337
)
2438
return cmd
2539
}
@@ -28,7 +42,13 @@ func NewBuilderCommand(dockerCli command.Cli) *cobra.Command {
2842
// This command is a placeholder / stub that is dynamically replaced by an
2943
// alias for "docker buildx bake" if BuildKit is enabled (and the buildx plugin
3044
// installed).
45+
//
46+
// Deprecated: Do not import commands directly. They will be removed in a future release.
3147
func NewBakeStubCommand(dockerCLI command.Streams) *cobra.Command {
48+
return newBakeStubCommand(dockerCLI)
49+
}
50+
51+
func newBakeStubCommand(dockerCLI command.Streams) *cobra.Command {
3252
return &cobra.Command{
3353
Use: "bake [OPTIONS] [TARGET...]",
3454
Short: "Build from a file",

0 commit comments

Comments
 (0)