diff --git a/cli/command/commands/commands.go b/cli/command/commands/commands.go index a735e36d8..8abe3a3ac 100644 --- a/cli/command/commands/commands.go +++ b/cli/command/commands/commands.go @@ -46,7 +46,9 @@ func AddCommands(cmd *cobra.Command, dockerCli command.Cli) { registry.NewLoginCommand(dockerCli), registry.NewLogoutCommand(dockerCli), registry.NewSearchCommand(dockerCli), + //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) system.NewVersionCommand(dockerCli), + //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) system.NewInfoCommand(dockerCli), // management commands @@ -64,6 +66,7 @@ func AddCommands(cmd *cobra.Command, dockerCli command.Cli) { manifest.NewManifestCommand(dockerCli), network.NewNetworkCommand(dockerCli), plugin.NewPluginCommand(dockerCli), + //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) system.NewSystemCommand(dockerCli), trust.NewTrustCommand(dockerCli), volume.NewVolumeCommand(dockerCli), @@ -130,7 +133,9 @@ func AddCommands(cmd *cobra.Command, dockerCli command.Cli) { hide(image.NewSaveCommand(dockerCli)), //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) hide(image.NewTagCommand(dockerCli)), + //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) hide(system.NewEventsCommand(dockerCli)), + //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) hide(system.NewInspectCommand(dockerCli)), ) } diff --git a/cli/command/system/cmd.go b/cli/command/system/cmd.go index 6accb98f0..2d0dcf441 100644 --- a/cli/command/system/cmd.go +++ b/cli/command/system/cmd.go @@ -7,19 +7,26 @@ import ( ) // NewSystemCommand returns a cobra command for `system` subcommands -func NewSystemCommand(dockerCli command.Cli) *cobra.Command { +// +// Deprecated: Do not import commands directly. They will be removed in a future release. +func NewSystemCommand(dockerCLI command.Cli) *cobra.Command { + return newSystemCommand(dockerCLI) +} + +// newSystemCommand returns a cobra command for `system` subcommands +func newSystemCommand(dockerCLI command.Cli) *cobra.Command { cmd := &cobra.Command{ Use: "system", Short: "Manage Docker", Args: cli.NoArgs, - RunE: command.ShowHelp(dockerCli.Err()), + RunE: command.ShowHelp(dockerCLI.Err()), } cmd.AddCommand( - NewEventsCommand(dockerCli), - NewInfoCommand(dockerCli), - newDiskUsageCommand(dockerCli), - newPruneCommand(dockerCli), - newDialStdioCommand(dockerCli), + newEventsCommand(dockerCLI), + newInfoCommand(dockerCLI), + newDiskUsageCommand(dockerCLI), + newPruneCommand(dockerCLI), + newDialStdioCommand(dockerCLI), ) return cmd diff --git a/cli/command/system/completion_test.go b/cli/command/system/completion_test.go index 76646a8a1..ecea8a4fa 100644 --- a/cli/command/system/completion_test.go +++ b/cli/command/system/completion_test.go @@ -156,7 +156,7 @@ func TestCompleteEventFilter(t *testing.T) { for _, tc := range tests { cli := test.NewFakeCli(tc.client) - completions, directive := completeEventFilters(cli)(NewEventsCommand(cli), nil, tc.toComplete) + completions, directive := completeEventFilters(cli)(newEventsCommand(cli), nil, tc.toComplete) assert.DeepEqual(t, completions, tc.expected) assert.Equal(t, directive, cobra.ShellCompDirectiveNoFileComp, fmt.Sprintf("wrong directive in completion for '%s'", tc.toComplete)) diff --git a/cli/command/system/events.go b/cli/command/system/events.go index 0ba1f6e4c..93df3d97d 100644 --- a/cli/command/system/events.go +++ b/cli/command/system/events.go @@ -28,7 +28,14 @@ type eventsOptions struct { } // NewEventsCommand creates a new cobra.Command for `docker events` -func NewEventsCommand(dockerCli command.Cli) *cobra.Command { +// +// Deprecated: Do not import commands directly. They will be removed in a future release. +func NewEventsCommand(dockerCLI command.Cli) *cobra.Command { + return newEventsCommand(dockerCLI) +} + +// newEventsCommand creates a new cobra.Command for `docker events` +func newEventsCommand(dockerCLI command.Cli) *cobra.Command { options := eventsOptions{filter: opts.NewFilterOpt()} cmd := &cobra.Command{ @@ -36,7 +43,7 @@ func NewEventsCommand(dockerCli command.Cli) *cobra.Command { Short: "Get real time events from the server", Args: cli.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { - return runEvents(cmd.Context(), dockerCli, &options) + return runEvents(cmd.Context(), dockerCLI, &options) }, Annotations: map[string]string{ "aliases": "docker system events, docker events", @@ -50,7 +57,7 @@ func NewEventsCommand(dockerCli command.Cli) *cobra.Command { flags.VarP(&options.filter, "filter", "f", "Filter output based on conditions provided") flags.StringVar(&options.format, "format", "", flagsHelper.InspectFormatHelp) // using the same flag description as "inspect" commands for now. - _ = cmd.RegisterFlagCompletionFunc("filter", completeEventFilters(dockerCli)) + _ = cmd.RegisterFlagCompletionFunc("filter", completeEventFilters(dockerCLI)) return cmd } diff --git a/cli/command/system/events_test.go b/cli/command/system/events_test.go index b5a825ac9..c2301f88e 100644 --- a/cli/command/system/events_test.go +++ b/cli/command/system/events_test.go @@ -70,7 +70,7 @@ func TestEventsFormat(t *testing.T) { }() return messages, errs }}) - cmd := NewEventsCommand(cli) + cmd := newEventsCommand(cli) cmd.SetArgs(tc.args) cmd.SetOut(io.Discard) cmd.SetErr(io.Discard) diff --git a/cli/command/system/info.go b/cli/command/system/info.go index e6f56b5ad..eef9430d1 100644 --- a/cli/command/system/info.go +++ b/cli/command/system/info.go @@ -60,7 +60,14 @@ func (i *dockerInfo) clientPlatform() string { } // NewInfoCommand creates a new cobra.Command for `docker info` -func NewInfoCommand(dockerCli command.Cli) *cobra.Command { +// +// Deprecated: Do not import commands directly. They will be removed in a future release. +func NewInfoCommand(dockerCLI command.Cli) *cobra.Command { + return newInfoCommand(dockerCLI) +} + +// newInfoCommand creates a new cobra.Command for `docker info` +func newInfoCommand(dockerCLI command.Cli) *cobra.Command { var opts infoOptions cmd := &cobra.Command{ @@ -68,7 +75,7 @@ func NewInfoCommand(dockerCli command.Cli) *cobra.Command { Short: "Display system-wide information", Args: cli.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { - return runInfo(cmd.Context(), cmd, dockerCli, &opts) + return runInfo(cmd.Context(), cmd, dockerCLI, &opts) }, Annotations: map[string]string{ "category-top": "12", diff --git a/cli/command/system/inspect.go b/cli/command/system/inspect.go index 8865678db..747e7eeec 100644 --- a/cli/command/system/inspect.go +++ b/cli/command/system/inspect.go @@ -60,7 +60,14 @@ type inspectOptions struct { } // NewInspectCommand creates a new cobra.Command for `docker inspect` -func NewInspectCommand(dockerCli command.Cli) *cobra.Command { +// +// Deprecated: Do not import commands directly. They will be removed in a future release. +func NewInspectCommand(dockerCLI command.Cli) *cobra.Command { + return newInspectCommand(dockerCLI) +} + +// newInspectCommand creates a new cobra.Command for `docker inspect` +func newInspectCommand(dockerCLI command.Cli) *cobra.Command { var opts inspectOptions cmd := &cobra.Command{ @@ -72,7 +79,7 @@ func NewInspectCommand(dockerCli command.Cli) *cobra.Command { if cmd.Flags().Changed("type") && opts.objectType == "" { return fmt.Errorf(`type is empty: must be one of "%s"`, strings.Join(allTypes, `", "`)) } - return runInspect(cmd.Context(), dockerCli, opts) + return runInspect(cmd.Context(), dockerCLI, opts) }, // TODO(thaJeztah): should we consider adding completion for common object-types? (images, containers?) ValidArgsFunction: completion.NoComplete, diff --git a/cli/command/system/inspect_test.go b/cli/command/system/inspect_test.go index 56ad5fd5b..3fbadc7f6 100644 --- a/cli/command/system/inspect_test.go +++ b/cli/command/system/inspect_test.go @@ -32,7 +32,7 @@ func TestInspectValidateFlagsAndArgs(t *testing.T) { }, } { t.Run(tc.name, func(t *testing.T) { - cmd := NewInspectCommand(test.NewFakeCli(&fakeClient{})) + cmd := newInspectCommand(test.NewFakeCli(&fakeClient{})) cmd.SetOut(io.Discard) cmd.SetErr(io.Discard) cmd.SetArgs(tc.args) diff --git a/cli/command/system/version.go b/cli/command/system/version.go index 499a8b648..ea67ac1ca 100644 --- a/cli/command/system/version.go +++ b/cli/command/system/version.go @@ -109,7 +109,14 @@ func newClientVersion(contextName string, dockerCli command.Cli) clientVersion { } // NewVersionCommand creates a new cobra.Command for `docker version` -func NewVersionCommand(dockerCli command.Cli) *cobra.Command { +// +// Deprecated: Do not import commands directly. They will be removed in a future release. +func NewVersionCommand(dockerCLI command.Cli) *cobra.Command { + return newVersionCommand(dockerCLI) +} + +// newVersionCommand creates a new cobra.Command for `docker version` +func newVersionCommand(dockerCLI command.Cli) *cobra.Command { var opts versionOptions cmd := &cobra.Command{ @@ -117,7 +124,7 @@ func NewVersionCommand(dockerCli command.Cli) *cobra.Command { Short: "Show the Docker version information", Args: cli.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { - return runVersion(cmd.Context(), dockerCli, &opts) + return runVersion(cmd.Context(), dockerCLI, &opts) }, Annotations: map[string]string{ "category-top": "10", diff --git a/cli/command/system/version_test.go b/cli/command/system/version_test.go index 45ad6fd55..1fd6a6886 100644 --- a/cli/command/system/version_test.go +++ b/cli/command/system/version_test.go @@ -20,7 +20,7 @@ func TestVersionWithoutServer(t *testing.T) { return types.Version{}, errors.New("no server") }, }) - cmd := NewVersionCommand(cli) + cmd := newVersionCommand(cli) cmd.SetArgs([]string{}) cmd.SetOut(cli.Err()) cmd.SetErr(io.Discard)