Skip to content

Commit 642adae

Browse files
authored
Merge pull request #6316 from Benehiko/command/network
Unexport network commands
2 parents 4643b42 + 78a8856 commit 642adae

File tree

4 files changed

+28
-13
lines changed

4 files changed

+28
-13
lines changed

cli/command/commands/commands.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func AddCommands(cmd *cobra.Command, dockerCli command.Cli) {
6464
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
6565
image.NewImageCommand(dockerCli),
6666
manifest.NewManifestCommand(dockerCli),
67+
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
6768
network.NewNetworkCommand(dockerCli),
6869
plugin.NewPluginCommand(dockerCli),
6970
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)

cli/command/network/cmd.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,29 @@ import (
77
)
88

99
// NewNetworkCommand returns a cobra command for `network` subcommands
10-
func NewNetworkCommand(dockerCli command.Cli) *cobra.Command {
10+
//
11+
// Deprecated: Do not import commands directly. They will be removed in a future release.
12+
func NewNetworkCommand(dockerCLI command.Cli) *cobra.Command {
13+
return newNetworkCommand(dockerCLI)
14+
}
15+
16+
// newNetworkCommand returns a cobra command for `network` subcommands
17+
func newNetworkCommand(dockerCLI command.Cli) *cobra.Command {
1118
cmd := &cobra.Command{
1219
Use: "network",
1320
Short: "Manage networks",
1421
Args: cli.NoArgs,
15-
RunE: command.ShowHelp(dockerCli.Err()),
22+
RunE: command.ShowHelp(dockerCLI.Err()),
1623
Annotations: map[string]string{"version": "1.21"},
1724
}
1825
cmd.AddCommand(
19-
newConnectCommand(dockerCli),
20-
newCreateCommand(dockerCli),
21-
newDisconnectCommand(dockerCli),
22-
newInspectCommand(dockerCli),
23-
newListCommand(dockerCli),
24-
newRemoveCommand(dockerCli),
25-
NewPruneCommand(dockerCli),
26+
newConnectCommand(dockerCLI),
27+
newCreateCommand(dockerCLI),
28+
newDisconnectCommand(dockerCLI),
29+
newInspectCommand(dockerCLI),
30+
newListCommand(dockerCLI),
31+
newRemoveCommand(dockerCLI),
32+
newPruneCommand(dockerCLI),
2633
)
2734
return cmd
2835
}

cli/command/network/prune.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,27 @@ type pruneOptions struct {
2626
}
2727

2828
// NewPruneCommand returns a new cobra prune command for networks
29-
func NewPruneCommand(dockerCli command.Cli) *cobra.Command {
29+
//
30+
// Deprecated: Do not import commands directly. They will be removed in a future release.
31+
func NewPruneCommand(dockerCLI command.Cli) *cobra.Command {
32+
return newPruneCommand(dockerCLI)
33+
}
34+
35+
// newPruneCommand returns a new cobra prune command for networks
36+
func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
3037
options := pruneOptions{filter: opts.NewFilterOpt()}
3138

3239
cmd := &cobra.Command{
3340
Use: "prune [OPTIONS]",
3441
Short: "Remove all unused networks",
3542
Args: cli.NoArgs,
3643
RunE: func(cmd *cobra.Command, args []string) error {
37-
output, err := runPrune(cmd.Context(), dockerCli, options)
44+
output, err := runPrune(cmd.Context(), dockerCLI, options)
3845
if err != nil {
3946
return err
4047
}
4148
if output != "" {
42-
_, _ = fmt.Fprintln(dockerCli.Out(), output)
49+
_, _ = fmt.Fprintln(dockerCLI.Out(), output)
4350
}
4451
return nil
4552
},

cli/command/network/prune_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestNetworkPrunePromptTermination(t *testing.T) {
2020
return network.PruneReport{}, errors.New("fakeClient networkPruneFunc should not be called")
2121
},
2222
})
23-
cmd := NewPruneCommand(cli)
23+
cmd := newPruneCommand(cli)
2424
cmd.SetArgs([]string{})
2525
cmd.SetOut(io.Discard)
2626
cmd.SetErr(io.Discard)

0 commit comments

Comments
 (0)