Skip to content

Commit a1f10b6

Browse files
committed
Unexport network commands
This patch deprecates exported network commands and moves the implementation details to an unexported function. Commands that are affected include: - network.NewNetworkCommand - network.NewPruneCommand Signed-off-by: Alano Terblanche <[email protected]>
1 parent 4643b42 commit a1f10b6

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
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: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,26 @@ 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+
func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
3036
options := pruneOptions{filter: opts.NewFilterOpt()}
3137

3238
cmd := &cobra.Command{
3339
Use: "prune [OPTIONS]",
3440
Short: "Remove all unused networks",
3541
Args: cli.NoArgs,
3642
RunE: func(cmd *cobra.Command, args []string) error {
37-
output, err := runPrune(cmd.Context(), dockerCli, options)
43+
output, err := runPrune(cmd.Context(), dockerCLI, options)
3844
if err != nil {
3945
return err
4046
}
4147
if output != "" {
42-
_, _ = fmt.Fprintln(dockerCli.Out(), output)
48+
_, _ = fmt.Fprintln(dockerCLI.Out(), output)
4349
}
4450
return nil
4551
},

0 commit comments

Comments
 (0)