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 <18033717+Benehiko@users.noreply.github.com>
This commit is contained in:
@ -7,22 +7,29 @@ import (
|
||||
)
|
||||
|
||||
// NewNetworkCommand returns a cobra command for `network` subcommands
|
||||
func NewNetworkCommand(dockerCli command.Cli) *cobra.Command {
|
||||
//
|
||||
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||
func NewNetworkCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
return newNetworkCommand(dockerCLI)
|
||||
}
|
||||
|
||||
// newNetworkCommand returns a cobra command for `network` subcommands
|
||||
func newNetworkCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "network",
|
||||
Short: "Manage networks",
|
||||
Args: cli.NoArgs,
|
||||
RunE: command.ShowHelp(dockerCli.Err()),
|
||||
RunE: command.ShowHelp(dockerCLI.Err()),
|
||||
Annotations: map[string]string{"version": "1.21"},
|
||||
}
|
||||
cmd.AddCommand(
|
||||
newConnectCommand(dockerCli),
|
||||
newCreateCommand(dockerCli),
|
||||
newDisconnectCommand(dockerCli),
|
||||
newInspectCommand(dockerCli),
|
||||
newListCommand(dockerCli),
|
||||
newRemoveCommand(dockerCli),
|
||||
NewPruneCommand(dockerCli),
|
||||
newConnectCommand(dockerCLI),
|
||||
newCreateCommand(dockerCLI),
|
||||
newDisconnectCommand(dockerCLI),
|
||||
newInspectCommand(dockerCLI),
|
||||
newListCommand(dockerCLI),
|
||||
newRemoveCommand(dockerCLI),
|
||||
newPruneCommand(dockerCLI),
|
||||
)
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -26,7 +26,14 @@ type pruneOptions struct {
|
||||
}
|
||||
|
||||
// NewPruneCommand returns a new cobra prune command for networks
|
||||
func NewPruneCommand(dockerCli command.Cli) *cobra.Command {
|
||||
//
|
||||
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||
func NewPruneCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
return newPruneCommand(dockerCLI)
|
||||
}
|
||||
|
||||
// newPruneCommand returns a new cobra prune command for networks
|
||||
func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
options := pruneOptions{filter: opts.NewFilterOpt()}
|
||||
|
||||
cmd := &cobra.Command{
|
||||
@ -34,12 +41,12 @@ func NewPruneCommand(dockerCli command.Cli) *cobra.Command {
|
||||
Short: "Remove all unused networks",
|
||||
Args: cli.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
output, err := runPrune(cmd.Context(), dockerCli, options)
|
||||
output, err := runPrune(cmd.Context(), dockerCLI, options)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if output != "" {
|
||||
_, _ = fmt.Fprintln(dockerCli.Out(), output)
|
||||
_, _ = fmt.Fprintln(dockerCLI.Out(), output)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
||||
@ -20,7 +20,7 @@ func TestNetworkPrunePromptTermination(t *testing.T) {
|
||||
return network.PruneReport{}, errors.New("fakeClient networkPruneFunc should not be called")
|
||||
},
|
||||
})
|
||||
cmd := NewPruneCommand(cli)
|
||||
cmd := newPruneCommand(cli)
|
||||
cmd.SetArgs([]string{})
|
||||
cmd.SetOut(io.Discard)
|
||||
cmd.SetErr(io.Discard)
|
||||
|
||||
Reference in New Issue
Block a user