From 3b0edc794c1a4fedb910e900cc51839a0d0c6ac4 Mon Sep 17 00:00:00 2001 From: Alano Terblanche <18033717+Benehiko@users.noreply.github.com> Date: Wed, 20 Aug 2025 13:22:47 +0200 Subject: [PATCH] Unexport context command This patch deprecates exported context commands and moves the implementation details to an unexported function. Commands that are affected include: - context.NewContextCommand Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com> --- cli/command/commands/commands.go | 1 + cli/command/context/cmd.go | 29 ++++++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/cli/command/commands/commands.go b/cli/command/commands/commands.go index cae16c0e01..92633fbeac 100644 --- a/cli/command/commands/commands.go +++ b/cli/command/commands/commands.go @@ -60,6 +60,7 @@ func AddCommands(cmd *cobra.Command, dockerCli command.Cli) { checkpoint.NewCheckpointCommand(dockerCli), //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) container.NewContainerCommand(dockerCli), + //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) context.NewContextCommand(dockerCli), //nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283) image.NewImageCommand(dockerCli), diff --git a/cli/command/context/cmd.go b/cli/command/context/cmd.go index f8b9e80d93..f50e0f248f 100644 --- a/cli/command/context/cmd.go +++ b/cli/command/context/cmd.go @@ -7,23 +7,30 @@ import ( ) // NewContextCommand returns the context cli subcommand -func NewContextCommand(dockerCli command.Cli) *cobra.Command { +// +// Deprecated: Do not import commands directly. They will be removed in a future release. +func NewContextCommand(dockerCLI command.Cli) *cobra.Command { + return newContextCommand(dockerCLI) +} + +// newContextCommand returns the context cli subcommand +func newContextCommand(dockerCLI command.Cli) *cobra.Command { cmd := &cobra.Command{ Use: "context", Short: "Manage contexts", Args: cli.NoArgs, - RunE: command.ShowHelp(dockerCli.Err()), + RunE: command.ShowHelp(dockerCLI.Err()), } cmd.AddCommand( - newCreateCommand(dockerCli), - newListCommand(dockerCli), - newUseCommand(dockerCli), - newExportCommand(dockerCli), - newImportCommand(dockerCli), - newRemoveCommand(dockerCli), - newUpdateCommand(dockerCli), - newInspectCommand(dockerCli), - newShowCommand(dockerCli), + newCreateCommand(dockerCLI), + newListCommand(dockerCLI), + newUseCommand(dockerCLI), + newExportCommand(dockerCLI), + newImportCommand(dockerCLI), + newRemoveCommand(dockerCLI), + newUpdateCommand(dockerCLI), + newInspectCommand(dockerCLI), + newShowCommand(dockerCLI), ) return cmd }