Skip to content

Conversation

@Benehiko
Copy link
Member

This patch deprecates exported container commands and moves the implementation details to an unexported function.

Commands that are affected include:

  • container.NewRunCommand
  • container.NewExecCommand
  • container.NewPsCommand
  • container.NewContainerCommand
  • container.NewAttachCommand
  • container.NewCommitCommand
  • container.NewCopyCommand
  • container.NewCreateCommand
  • container.NewDiffCommand
  • container.NewExportCommand
  • container.NewKillCommand
  • container.NewLogsCommand
  • container.NewPauseCommand
  • container.NewPortCommand
  • container.NewRenameCommand
  • container.NewRestartCommand
  • container.NewRmCommand
  • container.NewStartCommand
  • container.NewStatsCommand
  • container.NewStopCommand
  • container.NewTopCommand
  • container.NewUnpauseCommand
  • container.NewUpdateCommand
  • container.NewWaitCommand
  • container.NewPruneCommand

- What I did

- How I did it

- How to verify it

- Human readable description for the release notes

Go SDK: cli/command/container: deprecate `NewRunCommand`, `NewExecCommand`, `NewPsCommand`, `NewContainerCommand`, `NewAttachCommand`, `NewCommitCommand`, `NewCopyCommand`, `NewCreateCommand`, `NewDiffCommand`, `NewExportCommand`, `NewKillCommand`, `NewLogsCommand`, `NewPauseCommand`, `NewPortCommand`, `NewRenameCommand`, `NewRestartCommand`, `NewRmCommand`, `NewStartCommand`, `NewStatsCommand`, `NewStopCommand`, `NewTopCommand`, `NewUnpauseCommand`, `NewUpdateCommand`, `NewWaitCommand`, `NewPruneCommand`. These functions will be removed in the next release.

- A picture of a cute animal (not mandatory but encouraged)

This patch deprecates exported container commands and moves the
implementation details to an unexported function.

Commands that are affected include:
- container.NewRunCommand
- container.NewExecCommand
- container.NewPsCommand
- container.NewContainerCommand
- container.NewAttachCommand
- container.NewCommitCommand
- container.NewCopyCommand
- container.NewCreateCommand
- container.NewDiffCommand
- container.NewExportCommand
- container.NewKillCommand
- container.NewLogsCommand
- container.NewPauseCommand
- container.NewPortCommand
- container.NewRenameCommand
- container.NewRestartCommand
- container.NewRmCommand
- container.NewStartCommand
- container.NewStatsCommand
- container.NewStopCommand
- container.NewTopCommand
- container.NewUnpauseCommand
- container.NewUpdateCommand
- container.NewWaitCommand
- container.NewPruneCommand

Signed-off-by: Alano Terblanche <[email protected]>
@Benehiko Benehiko added impact/changelog impact/deprecation kind/refactor PR's that refactor, or clean-up code area/go-sdk Changes affecting the Go SDK impact/go-sdk Noteworthy (compatibility changes) in the Go SDK labels Aug 19, 2025
@Benehiko Benehiko added this to the 29.0.0 milestone Aug 19, 2025
@Benehiko Benehiko requested review from Copilot and thaJeztah August 19, 2025 09:23
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request deprecates all exported container command functions in the Docker CLI and moves their implementations to unexported functions. The changes are part of a broader effort to clean up the public API and prevent direct imports of command implementations.

  • Adds deprecation warnings to all exported New*Command functions
  • Creates new unexported new*Command functions with the actual implementation
  • Updates test files to use the new unexported functions
  • Adds //nolint:staticcheck comments for continued use in command registration

Reviewed Changes

Copilot reviewed 42 out of 42 changed files in this pull request and generated no comments.

File Description
cli/command/container/*.go Container command files with deprecation wrappers and implementation moves
cli/command/container/*_test.go Test files updated to use unexported functions
cli/command/container/cmd.go Container command registry updated to use unexported functions
cli/command/commands/commands.go Main command registry with staticcheck suppressions for deprecated functions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Comment on lines 66 to +73
// NewStatsCommand creates a new [cobra.Command] for "docker stats".
//
// Deprecated: Do not import commands directly. They will be removed in a future release.
func NewStatsCommand(dockerCLI command.Cli) *cobra.Command {
return newStatsCommand(dockerCLI)
}

func newStatsCommand(dockerCLI command.Cli) *cobra.Command {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh; just so I don't forget; when we remove the exported ones, I think it's still good to keep the GoDoc, and put those on the non-exported commands.

Admitted, most of them are rather boilerplate GoDocs, but it's still a "start", and can help encourage better documenting those where it adds value 😅

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@thaJeztah thaJeztah merged commit fcb260d into docker:master Aug 19, 2025
122 of 124 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/go-sdk Changes affecting the Go SDK impact/changelog impact/deprecation impact/go-sdk Noteworthy (compatibility changes) in the Go SDK kind/refactor PR's that refactor, or clean-up code process/cherry-picked

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants