mirror of https://github.com/docker/cli.git
Merge pull request #6312 from thaJeztah/28.x_backport_deprecate_cobra_commands
[28.x backport] un-export and deprecate cobra commands
This commit is contained in:
commit
85512e35cd
|
|
@ -9,17 +9,25 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewBuilderCommand returns a cobra command for `builder` subcommands
|
// NewBuilderCommand returns a cobra command for `builder` subcommands
|
||||||
func NewBuilderCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewBuilderCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newBuilderCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newBuilderCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "builder",
|
Use: "builder",
|
||||||
Short: "Manage builds",
|
Short: "Manage builds",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: command.ShowHelp(dockerCli.Err()),
|
RunE: command.ShowHelp(dockerCLI.Err()),
|
||||||
Annotations: map[string]string{"version": "1.31"},
|
Annotations: map[string]string{"version": "1.31"},
|
||||||
}
|
}
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
NewPruneCommand(dockerCli),
|
NewPruneCommand(dockerCLI),
|
||||||
image.NewBuildCommand(dockerCli),
|
// we should have a mechanism for registering sub-commands in the cli/internal/commands.Register function.
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
|
image.NewBuildCommand(dockerCLI),
|
||||||
)
|
)
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
@ -28,7 +36,13 @@ func NewBuilderCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
// This command is a placeholder / stub that is dynamically replaced by an
|
// This command is a placeholder / stub that is dynamically replaced by an
|
||||||
// alias for "docker buildx bake" if BuildKit is enabled (and the buildx plugin
|
// alias for "docker buildx bake" if BuildKit is enabled (and the buildx plugin
|
||||||
// installed).
|
// installed).
|
||||||
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
func NewBakeStubCommand(dockerCLI command.Streams) *cobra.Command {
|
func NewBakeStubCommand(dockerCLI command.Streams) *cobra.Command {
|
||||||
|
return newBakeStubCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newBakeStubCommand(dockerCLI command.Streams) *cobra.Command {
|
||||||
return &cobra.Command{
|
return &cobra.Command{
|
||||||
Use: "bake [OPTIONS] [TARGET...]",
|
Use: "bake [OPTIONS] [TARGET...]",
|
||||||
Short: "Build from a file",
|
Short: "Build from a file",
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,18 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewCheckpointCommand returns the `checkpoint` subcommand (only in experimental)
|
// NewCheckpointCommand returns the `checkpoint` subcommand (only in experimental)
|
||||||
func NewCheckpointCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewCheckpointCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newCheckpointCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newCheckpointCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "checkpoint",
|
Use: "checkpoint",
|
||||||
Short: "Manage checkpoints",
|
Short: "Manage checkpoints",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: command.ShowHelp(dockerCli.Err()),
|
RunE: command.ShowHelp(dockerCLI.Err()),
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"experimental": "",
|
"experimental": "",
|
||||||
"ostype": "linux",
|
"ostype": "linux",
|
||||||
|
|
@ -20,9 +26,9 @@ func NewCheckpointCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
newCreateCommand(dockerCli),
|
newCreateCommand(dockerCLI),
|
||||||
newListCommand(dockerCli),
|
newListCommand(dockerCLI),
|
||||||
newRemoveCommand(dockerCli),
|
newRemoveCommand(dockerCLI),
|
||||||
)
|
)
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,69 +29,127 @@ import (
|
||||||
func AddCommands(cmd *cobra.Command, dockerCli command.Cli) {
|
func AddCommands(cmd *cobra.Command, dockerCli command.Cli) {
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
// commonly used shorthands
|
// commonly used shorthands
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
container.NewRunCommand(dockerCli),
|
container.NewRunCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
container.NewExecCommand(dockerCli),
|
container.NewExecCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
container.NewPsCommand(dockerCli),
|
container.NewPsCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
image.NewBuildCommand(dockerCli),
|
image.NewBuildCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
image.NewPullCommand(dockerCli),
|
image.NewPullCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
image.NewPushCommand(dockerCli),
|
image.NewPushCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
image.NewImagesCommand(dockerCli),
|
image.NewImagesCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
registry.NewLoginCommand(dockerCli),
|
registry.NewLoginCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
registry.NewLogoutCommand(dockerCli),
|
registry.NewLogoutCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
registry.NewSearchCommand(dockerCli),
|
registry.NewSearchCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
system.NewVersionCommand(dockerCli),
|
system.NewVersionCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
system.NewInfoCommand(dockerCli),
|
system.NewInfoCommand(dockerCli),
|
||||||
|
|
||||||
// management commands
|
// management commands
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
builder.NewBakeStubCommand(dockerCli),
|
builder.NewBakeStubCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
builder.NewBuilderCommand(dockerCli),
|
builder.NewBuilderCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
checkpoint.NewCheckpointCommand(dockerCli),
|
checkpoint.NewCheckpointCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
container.NewContainerCommand(dockerCli),
|
container.NewContainerCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
context.NewContextCommand(dockerCli),
|
context.NewContextCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
image.NewImageCommand(dockerCli),
|
image.NewImageCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
manifest.NewManifestCommand(dockerCli),
|
manifest.NewManifestCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
network.NewNetworkCommand(dockerCli),
|
network.NewNetworkCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
plugin.NewPluginCommand(dockerCli),
|
plugin.NewPluginCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
system.NewSystemCommand(dockerCli),
|
system.NewSystemCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
trust.NewTrustCommand(dockerCli),
|
trust.NewTrustCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
volume.NewVolumeCommand(dockerCli),
|
volume.NewVolumeCommand(dockerCli),
|
||||||
|
|
||||||
// orchestration (swarm) commands
|
// orchestration (swarm) commands
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
config.NewConfigCommand(dockerCli),
|
config.NewConfigCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
node.NewNodeCommand(dockerCli),
|
node.NewNodeCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
secret.NewSecretCommand(dockerCli),
|
secret.NewSecretCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
service.NewServiceCommand(dockerCli),
|
service.NewServiceCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
stack.NewStackCommand(dockerCli),
|
stack.NewStackCommand(dockerCli),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
swarm.NewSwarmCommand(dockerCli),
|
swarm.NewSwarmCommand(dockerCli),
|
||||||
|
|
||||||
// legacy commands may be hidden
|
// legacy commands may be hidden
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(container.NewAttachCommand(dockerCli)),
|
hide(container.NewAttachCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(container.NewCommitCommand(dockerCli)),
|
hide(container.NewCommitCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(container.NewCopyCommand(dockerCli)),
|
hide(container.NewCopyCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(container.NewCreateCommand(dockerCli)),
|
hide(container.NewCreateCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(container.NewDiffCommand(dockerCli)),
|
hide(container.NewDiffCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(container.NewExportCommand(dockerCli)),
|
hide(container.NewExportCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(container.NewKillCommand(dockerCli)),
|
hide(container.NewKillCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(container.NewLogsCommand(dockerCli)),
|
hide(container.NewLogsCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(container.NewPauseCommand(dockerCli)),
|
hide(container.NewPauseCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(container.NewPortCommand(dockerCli)),
|
hide(container.NewPortCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(container.NewRenameCommand(dockerCli)),
|
hide(container.NewRenameCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(container.NewRestartCommand(dockerCli)),
|
hide(container.NewRestartCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(container.NewRmCommand(dockerCli)),
|
hide(container.NewRmCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(container.NewStartCommand(dockerCli)),
|
hide(container.NewStartCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(container.NewStatsCommand(dockerCli)),
|
hide(container.NewStatsCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(container.NewStopCommand(dockerCli)),
|
hide(container.NewStopCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(container.NewTopCommand(dockerCli)),
|
hide(container.NewTopCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(container.NewUnpauseCommand(dockerCli)),
|
hide(container.NewUnpauseCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(container.NewUpdateCommand(dockerCli)),
|
hide(container.NewUpdateCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(container.NewWaitCommand(dockerCli)),
|
hide(container.NewWaitCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(image.NewHistoryCommand(dockerCli)),
|
hide(image.NewHistoryCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(image.NewImportCommand(dockerCli)),
|
hide(image.NewImportCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(image.NewLoadCommand(dockerCli)),
|
hide(image.NewLoadCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(image.NewRemoveCommand(dockerCli)),
|
hide(image.NewRemoveCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(image.NewSaveCommand(dockerCli)),
|
hide(image.NewSaveCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(image.NewTagCommand(dockerCli)),
|
hide(image.NewTagCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(system.NewEventsCommand(dockerCli)),
|
hide(system.NewEventsCommand(dockerCli)),
|
||||||
|
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
|
||||||
hide(system.NewInspectCommand(dockerCli)),
|
hide(system.NewInspectCommand(dockerCli)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,22 +9,28 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewConfigCommand returns a cobra command for `config` subcommands
|
// NewConfigCommand returns a cobra command for `config` subcommands
|
||||||
func NewConfigCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewConfigCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newConfigCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newConfigCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "config",
|
Use: "config",
|
||||||
Short: "Manage Swarm configs",
|
Short: "Manage Swarm configs",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: command.ShowHelp(dockerCli.Err()),
|
RunE: command.ShowHelp(dockerCLI.Err()),
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"version": "1.30",
|
"version": "1.30",
|
||||||
"swarm": "manager",
|
"swarm": "manager",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
newConfigListCommand(dockerCli),
|
newConfigListCommand(dockerCLI),
|
||||||
newConfigCreateCommand(dockerCli),
|
newConfigCreateCommand(dockerCLI),
|
||||||
newConfigInspectCommand(dockerCli),
|
newConfigInspectCommand(dockerCLI),
|
||||||
newConfigRemoveCommand(dockerCli),
|
newConfigRemoveCommand(dockerCLI),
|
||||||
)
|
)
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,13 @@ func inspectContainerAndCheckState(ctx context.Context, apiClient client.APIClie
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewAttachCommand creates a new cobra.Command for `docker attach`
|
// NewAttachCommand creates a new cobra.Command for `docker attach`
|
||||||
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
func NewAttachCommand(dockerCLI command.Cli) *cobra.Command {
|
func NewAttachCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newAttachCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newAttachCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var opts AttachOptions
|
var opts AttachOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ func TestNewAttachCommandErrors(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
cmd := NewAttachCommand(test.NewFakeCli(&fakeClient{inspectFunc: tc.containerInspectFunc}))
|
cmd := newAttachCommand(test.NewFakeCli(&fakeClient{inspectFunc: tc.containerInspectFunc}))
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
|
||||||
|
|
@ -7,39 +7,45 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewContainerCommand returns a cobra command for `container` subcommands
|
// NewContainerCommand returns a cobra command for `container` subcommands
|
||||||
func NewContainerCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewContainerCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newContainerCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newContainerCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "container",
|
Use: "container",
|
||||||
Short: "Manage containers",
|
Short: "Manage containers",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: command.ShowHelp(dockerCli.Err()),
|
RunE: command.ShowHelp(dockerCLI.Err()),
|
||||||
}
|
}
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
NewAttachCommand(dockerCli),
|
newAttachCommand(dockerCLI),
|
||||||
NewCommitCommand(dockerCli),
|
newCommitCommand(dockerCLI),
|
||||||
NewCopyCommand(dockerCli),
|
newCopyCommand(dockerCLI),
|
||||||
NewCreateCommand(dockerCli),
|
newCreateCommand(dockerCLI),
|
||||||
NewDiffCommand(dockerCli),
|
newDiffCommand(dockerCLI),
|
||||||
NewExecCommand(dockerCli),
|
newExecCommand(dockerCLI),
|
||||||
NewExportCommand(dockerCli),
|
newExportCommand(dockerCLI),
|
||||||
NewKillCommand(dockerCli),
|
newKillCommand(dockerCLI),
|
||||||
NewLogsCommand(dockerCli),
|
newLogsCommand(dockerCLI),
|
||||||
NewPauseCommand(dockerCli),
|
newPauseCommand(dockerCLI),
|
||||||
NewPortCommand(dockerCli),
|
newPortCommand(dockerCLI),
|
||||||
NewRenameCommand(dockerCli),
|
newRenameCommand(dockerCLI),
|
||||||
NewRestartCommand(dockerCli),
|
newRestartCommand(dockerCLI),
|
||||||
newRemoveCommand(dockerCli),
|
newRemoveCommand(dockerCLI),
|
||||||
NewRunCommand(dockerCli),
|
newRunCommand(dockerCLI),
|
||||||
NewStartCommand(dockerCli),
|
newStartCommand(dockerCLI),
|
||||||
NewStatsCommand(dockerCli),
|
newStatsCommand(dockerCLI),
|
||||||
NewStopCommand(dockerCli),
|
newStopCommand(dockerCLI),
|
||||||
NewTopCommand(dockerCli),
|
newTopCommand(dockerCLI),
|
||||||
NewUnpauseCommand(dockerCli),
|
newUnpauseCommand(dockerCLI),
|
||||||
NewUpdateCommand(dockerCli),
|
newUpdateCommand(dockerCLI),
|
||||||
NewWaitCommand(dockerCli),
|
newWaitCommand(dockerCLI),
|
||||||
newListCommand(dockerCli),
|
newListCommand(dockerCLI),
|
||||||
newInspectCommand(dockerCli),
|
newInspectCommand(dockerCLI),
|
||||||
NewPruneCommand(dockerCli),
|
newPruneCommand(dockerCLI),
|
||||||
)
|
)
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,13 @@ type commitOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCommitCommand creates a new cobra.Command for `docker commit`
|
// NewCommitCommand creates a new cobra.Command for `docker commit`
|
||||||
func NewCommitCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewCommitCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newCommitCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newCommitCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var options commitOptions
|
var options commitOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -35,12 +41,12 @@ func NewCommitCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
if len(args) > 1 {
|
if len(args) > 1 {
|
||||||
options.reference = args[1]
|
options.reference = args[1]
|
||||||
}
|
}
|
||||||
return runCommit(cmd.Context(), dockerCli, &options)
|
return runCommit(cmd.Context(), dockerCLI, &options)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"aliases": "docker container commit, docker commit",
|
"aliases": "docker container commit, docker commit",
|
||||||
},
|
},
|
||||||
ValidArgsFunction: completion.ContainerNames(dockerCli, false),
|
ValidArgsFunction: completion.ContainerNames(dockerCLI, false),
|
||||||
}
|
}
|
||||||
|
|
||||||
flags := cmd.Flags()
|
flags := cmd.Flags()
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ func TestRunCommit(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
cmd := NewCommitCommand(cli)
|
cmd := newCommitCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetArgs(
|
cmd.SetArgs(
|
||||||
[]string{
|
[]string{
|
||||||
|
|
@ -60,7 +60,7 @@ func TestRunCommitClientError(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
cmd := NewCommitCommand(cli)
|
cmd := newCommitCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs([]string{"container-id"})
|
cmd.SetArgs([]string{"container-id"})
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ func TestCompletePid(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{
|
cli := test.NewFakeCli(&fakeClient{
|
||||||
containerListFunc: tc.containerListFunc,
|
containerListFunc: tc.containerListFunc,
|
||||||
})
|
})
|
||||||
completions, directive := completePid(cli)(NewRunCommand(cli), nil, tc.toComplete)
|
completions, directive := completePid(cli)(newRunCommand(cli), nil, tc.toComplete)
|
||||||
assert.Check(t, is.DeepEqual(completions, tc.expectedCompletions))
|
assert.Check(t, is.DeepEqual(completions, tc.expectedCompletions))
|
||||||
assert.Check(t, is.Equal(directive, tc.expectedDirective))
|
assert.Check(t, is.Equal(directive, tc.expectedDirective))
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,13 @@ func copyProgress(ctx context.Context, dst io.Writer, header string, total *int6
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCopyCommand creates a new `docker cp` command
|
// NewCopyCommand creates a new `docker cp` command
|
||||||
func NewCopyCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewCopyCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newCopyCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newCopyCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var opts copyOptions
|
var opts copyOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -147,9 +153,9 @@ container source to stdout.`,
|
||||||
opts.destination = args[1]
|
opts.destination = args[1]
|
||||||
if !cmd.Flag("quiet").Changed {
|
if !cmd.Flag("quiet").Changed {
|
||||||
// User did not specify "quiet" flag; suppress output if no terminal is attached
|
// User did not specify "quiet" flag; suppress output if no terminal is attached
|
||||||
opts.quiet = !dockerCli.Out().IsTerminal()
|
opts.quiet = !dockerCLI.Out().IsTerminal()
|
||||||
}
|
}
|
||||||
return runCopy(cmd.Context(), dockerCli, opts)
|
return runCopy(cmd.Context(), dockerCLI, opts)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"aliases": "docker container cp, docker cp",
|
"aliases": "docker container cp, docker cp",
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,13 @@ type createOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCreateCommand creates a new cobra.Command for `docker create`
|
// NewCreateCommand creates a new cobra.Command for `docker create`
|
||||||
func NewCreateCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewCreateCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newCreateCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newCreateCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var options createOptions
|
var options createOptions
|
||||||
var copts *containerOptions
|
var copts *containerOptions
|
||||||
|
|
||||||
|
|
@ -65,12 +71,12 @@ func NewCreateCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
if len(args) > 1 {
|
if len(args) > 1 {
|
||||||
copts.Args = args[1:]
|
copts.Args = args[1:]
|
||||||
}
|
}
|
||||||
return runCreate(cmd.Context(), dockerCli, cmd.Flags(), &options, copts)
|
return runCreate(cmd.Context(), dockerCLI, cmd.Flags(), &options, copts)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"aliases": "docker container create, docker create",
|
"aliases": "docker container create, docker create",
|
||||||
},
|
},
|
||||||
ValidArgsFunction: completion.ImageNames(dockerCli, -1),
|
ValidArgsFunction: completion.ImageNames(dockerCLI, -1),
|
||||||
}
|
}
|
||||||
|
|
||||||
flags := cmd.Flags()
|
flags := cmd.Flags()
|
||||||
|
|
@ -90,10 +96,10 @@ func NewCreateCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
addPlatformFlag(flags, &options.platform)
|
addPlatformFlag(flags, &options.platform)
|
||||||
_ = cmd.RegisterFlagCompletionFunc("platform", completion.Platforms)
|
_ = cmd.RegisterFlagCompletionFunc("platform", completion.Platforms)
|
||||||
|
|
||||||
flags.BoolVar(&options.untrusted, "disable-content-trust", !dockerCli.ContentTrustEnabled(), "Skip image verification")
|
flags.BoolVar(&options.untrusted, "disable-content-trust", !dockerCLI.ContentTrustEnabled(), "Skip image verification")
|
||||||
copts = addFlags(flags)
|
copts = addFlags(flags)
|
||||||
|
|
||||||
addCompletions(cmd, dockerCli)
|
addCompletions(cmd, dockerCLI)
|
||||||
|
|
||||||
flags.VisitAll(func(flag *pflag.Flag) {
|
flags.VisitAll(func(flag *pflag.Flag) {
|
||||||
// Set a default completion function if none was set. We don't look
|
// Set a default completion function if none was set. We don't look
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ func TestCreateContainerValidateFlags(t *testing.T) {
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
cmd := NewCreateCommand(test.NewFakeCli(&fakeClient{}))
|
cmd := newCreateCommand(test.NewFakeCli(&fakeClient{}))
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
@ -260,7 +260,7 @@ func TestNewCreateCommandWithContentTrustErrors(t *testing.T) {
|
||||||
},
|
},
|
||||||
}, test.EnableContentTrust)
|
}, test.EnableContentTrust)
|
||||||
fakeCLI.SetNotaryClient(tc.notaryFunc)
|
fakeCLI.SetNotaryClient(tc.notaryFunc)
|
||||||
cmd := NewCreateCommand(fakeCLI)
|
cmd := newCreateCommand(fakeCLI)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
@ -314,7 +314,7 @@ func TestNewCreateCommandWithWarnings(t *testing.T) {
|
||||||
return container.CreateResponse{Warnings: tc.warnings}, nil
|
return container.CreateResponse{Warnings: tc.warnings}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
cmd := NewCreateCommand(fakeCLI)
|
cmd := newCreateCommand(fakeCLI)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
|
|
@ -366,7 +366,7 @@ func TestCreateContainerWithProxyConfig(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
cmd := NewCreateCommand(fakeCLI)
|
cmd := newCreateCommand(fakeCLI)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetArgs([]string{"image:tag"})
|
cmd.SetArgs([]string{"image:tag"})
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
|
|
|
||||||
|
|
@ -11,18 +11,24 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewDiffCommand creates a new cobra.Command for `docker diff`
|
// NewDiffCommand creates a new cobra.Command for `docker diff`
|
||||||
func NewDiffCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewDiffCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newDiffCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newDiffCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
return &cobra.Command{
|
return &cobra.Command{
|
||||||
Use: "diff CONTAINER",
|
Use: "diff CONTAINER",
|
||||||
Short: "Inspect changes to files or directories on a container's filesystem",
|
Short: "Inspect changes to files or directories on a container's filesystem",
|
||||||
Args: cli.ExactArgs(1),
|
Args: cli.ExactArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
return runDiff(cmd.Context(), dockerCli, args[0])
|
return runDiff(cmd.Context(), dockerCLI, args[0])
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"aliases": "docker container diff, docker diff",
|
"aliases": "docker container diff, docker diff",
|
||||||
},
|
},
|
||||||
ValidArgsFunction: completion.ContainerNames(dockerCli, false),
|
ValidArgsFunction: completion.ContainerNames(dockerCLI, false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ func TestRunDiff(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
cmd := NewDiffCommand(cli)
|
cmd := newDiffCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
|
|
||||||
cmd.SetArgs([]string{"container-id"})
|
cmd.SetArgs([]string{"container-id"})
|
||||||
|
|
@ -68,7 +68,7 @@ func TestRunDiffClientError(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
cmd := NewDiffCommand(cli)
|
cmd := newDiffCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,13 @@ func NewExecOptions() ExecOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewExecCommand creates a new cobra.Command for `docker exec`
|
// NewExecCommand creates a new cobra.Command for `docker exec`
|
||||||
func NewExecCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewExecCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newExecCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newExecCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
options := NewExecOptions()
|
options := NewExecOptions()
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -50,9 +56,9 @@ func NewExecCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
containerIDorName := args[0]
|
containerIDorName := args[0]
|
||||||
options.Command = args[1:]
|
options.Command = args[1:]
|
||||||
return RunExec(cmd.Context(), dockerCli, containerIDorName, options)
|
return RunExec(cmd.Context(), dockerCLI, containerIDorName, options)
|
||||||
},
|
},
|
||||||
ValidArgsFunction: completion.ContainerNames(dockerCli, false, func(ctr container.Summary) bool {
|
ValidArgsFunction: completion.ContainerNames(dockerCLI, false, func(ctr container.Summary) bool {
|
||||||
return ctr.State != container.StatePaused
|
return ctr.State != container.StatePaused
|
||||||
}),
|
}),
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,7 @@ func TestNewExecCommandErrors(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
fakeCLI := test.NewFakeCli(&fakeClient{inspectFunc: tc.containerInspectFunc})
|
fakeCLI := test.NewFakeCli(&fakeClient{inspectFunc: tc.containerInspectFunc})
|
||||||
cmd := NewExecCommand(fakeCLI)
|
cmd := newExecCommand(fakeCLI)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,13 @@ type exportOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewExportCommand creates a new `docker export` command
|
// NewExportCommand creates a new `docker export` command
|
||||||
func NewExportCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewExportCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newExportCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newExportCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var opts exportOptions
|
var opts exportOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -27,12 +33,12 @@ func NewExportCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
Args: cli.ExactArgs(1),
|
Args: cli.ExactArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
opts.container = args[0]
|
opts.container = args[0]
|
||||||
return runExport(cmd.Context(), dockerCli, opts)
|
return runExport(cmd.Context(), dockerCLI, opts)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"aliases": "docker container export, docker export",
|
"aliases": "docker container export, docker export",
|
||||||
},
|
},
|
||||||
ValidArgsFunction: completion.ContainerNames(dockerCli, true),
|
ValidArgsFunction: completion.ContainerNames(dockerCLI, true),
|
||||||
}
|
}
|
||||||
|
|
||||||
flags := cmd.Flags()
|
flags := cmd.Flags()
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ func TestContainerExportOutputToFile(t *testing.T) {
|
||||||
return io.NopCloser(strings.NewReader("bar")), nil
|
return io.NopCloser(strings.NewReader("bar")), nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
cmd := NewExportCommand(cli)
|
cmd := newExportCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetArgs([]string{"-o", dir.Join("foo"), "container"})
|
cmd.SetArgs([]string{"-o", dir.Join("foo"), "container"})
|
||||||
assert.NilError(t, cmd.Execute())
|
assert.NilError(t, cmd.Execute())
|
||||||
|
|
@ -37,7 +37,7 @@ func TestContainerExportOutputToIrregularFile(t *testing.T) {
|
||||||
return io.NopCloser(strings.NewReader("foo")), nil
|
return io.NopCloser(strings.NewReader("foo")), nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
cmd := NewExportCommand(cli)
|
cmd := newExportCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs([]string{"-o", "/dev/random", "container"})
|
cmd.SetArgs([]string{"-o", "/dev/random", "container"})
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,13 @@ type killOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewKillCommand creates a new cobra.Command for `docker kill`
|
// NewKillCommand creates a new cobra.Command for `docker kill`
|
||||||
func NewKillCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewKillCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newKillCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newKillCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var opts killOptions
|
var opts killOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -27,12 +33,12 @@ func NewKillCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
Args: cli.RequiresMinArgs(1),
|
Args: cli.RequiresMinArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
opts.containers = args
|
opts.containers = args
|
||||||
return runKill(cmd.Context(), dockerCli, &opts)
|
return runKill(cmd.Context(), dockerCLI, &opts)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"aliases": "docker container kill, docker kill",
|
"aliases": "docker container kill, docker kill",
|
||||||
},
|
},
|
||||||
ValidArgsFunction: completion.ContainerNames(dockerCli, false),
|
ValidArgsFunction: completion.ContainerNames(dockerCLI, false),
|
||||||
}
|
}
|
||||||
|
|
||||||
flags := cmd.Flags()
|
flags := cmd.Flags()
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ func TestRunKill(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
cmd := NewKillCommand(cli)
|
cmd := newKillCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
|
|
||||||
cmd.SetArgs([]string{
|
cmd.SetArgs([]string{
|
||||||
|
|
@ -56,7 +56,7 @@ func TestRunKillClientError(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
cmd := NewKillCommand(cli)
|
cmd := newKillCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,13 @@ type psOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPsCommand creates a new cobra.Command for `docker ps`
|
// NewPsCommand creates a new cobra.Command for `docker ps`
|
||||||
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
func NewPsCommand(dockerCLI command.Cli) *cobra.Command {
|
func NewPsCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newPsCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newPsCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
options := psOptions{filter: opts.NewFilterOpt()}
|
options := psOptions{filter: opts.NewFilterOpt()}
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -62,7 +68,7 @@ func NewPsCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newListCommand(dockerCLI command.Cli) *cobra.Command {
|
func newListCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
cmd := *NewPsCommand(dockerCLI)
|
cmd := *newPsCommand(dockerCLI)
|
||||||
cmd.Aliases = []string{"ps", "list"}
|
cmd.Aliases = []string{"ps", "list"}
|
||||||
cmd.Use = "ls [OPTIONS]"
|
cmd.Use = "ls [OPTIONS]"
|
||||||
return &cmd
|
return &cmd
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,13 @@ type logsOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLogsCommand creates a new cobra.Command for `docker logs`
|
// NewLogsCommand creates a new cobra.Command for `docker logs`
|
||||||
func NewLogsCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewLogsCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newLogsCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newLogsCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var opts logsOptions
|
var opts logsOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -33,12 +39,12 @@ func NewLogsCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
Args: cli.ExactArgs(1),
|
Args: cli.ExactArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
opts.container = args[0]
|
opts.container = args[0]
|
||||||
return runLogs(cmd.Context(), dockerCli, &opts)
|
return runLogs(cmd.Context(), dockerCLI, &opts)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"aliases": "docker container logs, docker logs",
|
"aliases": "docker container logs, docker logs",
|
||||||
},
|
},
|
||||||
ValidArgsFunction: completion.ContainerNames(dockerCli, true),
|
ValidArgsFunction: completion.ContainerNames(dockerCLI, true),
|
||||||
}
|
}
|
||||||
|
|
||||||
flags := cmd.Flags()
|
flags := cmd.Flags()
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,13 @@ type pauseOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPauseCommand creates a new cobra.Command for `docker pause`
|
// NewPauseCommand creates a new cobra.Command for `docker pause`
|
||||||
func NewPauseCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewPauseCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newPauseCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newPauseCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var opts pauseOptions
|
var opts pauseOptions
|
||||||
|
|
||||||
return &cobra.Command{
|
return &cobra.Command{
|
||||||
|
|
@ -26,12 +32,12 @@ func NewPauseCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
Args: cli.RequiresMinArgs(1),
|
Args: cli.RequiresMinArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
opts.containers = args
|
opts.containers = args
|
||||||
return runPause(cmd.Context(), dockerCli, &opts)
|
return runPause(cmd.Context(), dockerCLI, &opts)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"aliases": "docker container pause, docker pause",
|
"aliases": "docker container pause, docker pause",
|
||||||
},
|
},
|
||||||
ValidArgsFunction: completion.ContainerNames(dockerCli, false, func(ctr container.Summary) bool {
|
ValidArgsFunction: completion.ContainerNames(dockerCLI, false, func(ctr container.Summary) bool {
|
||||||
return ctr.State != container.StatePaused
|
return ctr.State != container.StatePaused
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ func TestRunPause(t *testing.T) {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
cmd := NewPauseCommand(cli)
|
cmd := newPauseCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetArgs([]string{"container-id-1", "container-id-2"})
|
cmd.SetArgs([]string{"container-id-1", "container-id-2"})
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ func TestRunPauseClientError(t *testing.T) {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
cmd := NewPauseCommand(cli)
|
cmd := newPauseCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs([]string{"container-id-1", "container-id-2"})
|
cmd.SetArgs([]string{"container-id-1", "container-id-2"})
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,13 @@ type portOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPortCommand creates a new cobra.Command for `docker port`
|
// NewPortCommand creates a new cobra.Command for `docker port`
|
||||||
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
func NewPortCommand(dockerCli command.Cli) *cobra.Command {
|
func NewPortCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
|
return newPortCommand(dockerCli)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newPortCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
var opts portOptions
|
var opts portOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ func TestNewPortCommandOutput(t *testing.T) {
|
||||||
return ci, nil
|
return ci, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
cmd := NewPortCommand(cli)
|
cmd := newPortCommand(cli)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs([]string{"some_container", tc.port})
|
cmd.SetArgs([]string{"some_container", tc.port})
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,13 @@ type pruneOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPruneCommand returns a new cobra prune command for containers
|
// NewPruneCommand returns a new cobra prune command for containers
|
||||||
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
options := pruneOptions{filter: opts.NewFilterOpt()}
|
options := pruneOptions{filter: opts.NewFilterOpt()}
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -28,14 +34,14 @@ func NewPruneCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
Short: "Remove all stopped containers",
|
Short: "Remove all stopped containers",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
spaceReclaimed, output, err := runPrune(cmd.Context(), dockerCli, options)
|
spaceReclaimed, output, err := runPrune(cmd.Context(), dockerCLI, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if output != "" {
|
if output != "" {
|
||||||
fmt.Fprintln(dockerCli.Out(), output)
|
fmt.Fprintln(dockerCLI.Out(), output)
|
||||||
}
|
}
|
||||||
fmt.Fprintln(dockerCli.Out(), "Total reclaimed space:", units.HumanSize(float64(spaceReclaimed)))
|
fmt.Fprintln(dockerCLI.Out(), "Total reclaimed space:", units.HumanSize(float64(spaceReclaimed)))
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{"version": "1.25"},
|
Annotations: map[string]string{"version": "1.25"},
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ func TestContainerPrunePromptTermination(t *testing.T) {
|
||||||
return container.PruneReport{}, errors.New("fakeClient containerPruneFunc should not be called")
|
return container.PruneReport{}, errors.New("fakeClient containerPruneFunc should not be called")
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
cmd := NewPruneCommand(cli)
|
cmd := newPruneCommand(cli)
|
||||||
cmd.SetArgs([]string{})
|
cmd.SetArgs([]string{})
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,13 @@ type renameOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRenameCommand creates a new cobra.Command for `docker rename`
|
// NewRenameCommand creates a new cobra.Command for `docker rename`
|
||||||
func NewRenameCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewRenameCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newRenameCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newRenameCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var opts renameOptions
|
var opts renameOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -28,12 +34,12 @@ func NewRenameCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
opts.oldName = args[0]
|
opts.oldName = args[0]
|
||||||
opts.newName = args[1]
|
opts.newName = args[1]
|
||||||
return runRename(cmd.Context(), dockerCli, &opts)
|
return runRename(cmd.Context(), dockerCLI, &opts)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"aliases": "docker container rename, docker rename",
|
"aliases": "docker container rename, docker rename",
|
||||||
},
|
},
|
||||||
ValidArgsFunction: completion.ContainerNames(dockerCli, true),
|
ValidArgsFunction: completion.ContainerNames(dockerCLI, true),
|
||||||
}
|
}
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ func TestRunRename(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
cmd := NewRenameCommand(cli)
|
cmd := newRenameCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs([]string{tc.oldName, tc.newName})
|
cmd.SetArgs([]string{tc.oldName, tc.newName})
|
||||||
|
|
@ -66,7 +66,7 @@ func TestRunRenameClientError(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
cmd := NewRenameCommand(cli)
|
cmd := newRenameCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs([]string{"oldName", "newName"})
|
cmd.SetArgs([]string{"oldName", "newName"})
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,13 @@ type restartOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRestartCommand creates a new cobra.Command for `docker restart`
|
// NewRestartCommand creates a new cobra.Command for `docker restart`
|
||||||
func NewRestartCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewRestartCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newRestartCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newRestartCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var opts restartOptions
|
var opts restartOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -34,12 +40,12 @@ func NewRestartCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
}
|
}
|
||||||
opts.containers = args
|
opts.containers = args
|
||||||
opts.timeoutChanged = cmd.Flags().Changed("timeout") || cmd.Flags().Changed("time")
|
opts.timeoutChanged = cmd.Flags().Changed("timeout") || cmd.Flags().Changed("time")
|
||||||
return runRestart(cmd.Context(), dockerCli, &opts)
|
return runRestart(cmd.Context(), dockerCLI, &opts)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"aliases": "docker container restart, docker restart",
|
"aliases": "docker container restart, docker restart",
|
||||||
},
|
},
|
||||||
ValidArgsFunction: completion.ContainerNames(dockerCli, true),
|
ValidArgsFunction: completion.ContainerNames(dockerCLI, true),
|
||||||
}
|
}
|
||||||
|
|
||||||
flags := cmd.Flags()
|
flags := cmd.Flags()
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ func TestRestart(t *testing.T) {
|
||||||
},
|
},
|
||||||
Version: "1.36",
|
Version: "1.36",
|
||||||
})
|
})
|
||||||
cmd := NewRestartCommand(cli)
|
cmd := newRestartCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,13 @@ type rmOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRmCommand creates a new cobra.Command for `docker rm`
|
// NewRmCommand creates a new cobra.Command for `docker rm`
|
||||||
func NewRmCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewRmCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newRmCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newRmCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var opts rmOptions
|
var opts rmOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -32,12 +38,12 @@ func NewRmCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
Args: cli.RequiresMinArgs(1),
|
Args: cli.RequiresMinArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
opts.containers = args
|
opts.containers = args
|
||||||
return runRm(cmd.Context(), dockerCli, &opts)
|
return runRm(cmd.Context(), dockerCLI, &opts)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"aliases": "docker container rm, docker container remove, docker rm",
|
"aliases": "docker container rm, docker container remove, docker rm",
|
||||||
},
|
},
|
||||||
ValidArgsFunction: completion.ContainerNames(dockerCli, true, func(ctr container.Summary) bool {
|
ValidArgsFunction: completion.ContainerNames(dockerCLI, true, func(ctr container.Summary) bool {
|
||||||
return opts.force || ctr.State == container.StateExited || ctr.State == container.StateCreated
|
return opts.force || ctr.State == container.StateExited || ctr.State == container.StateCreated
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
@ -53,7 +59,7 @@ func NewRmCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
// top-level "docker rm", it also adds a "remove" alias to support
|
// top-level "docker rm", it also adds a "remove" alias to support
|
||||||
// "docker container remove" in addition to "docker container rm".
|
// "docker container remove" in addition to "docker container rm".
|
||||||
func newRemoveCommand(dockerCli command.Cli) *cobra.Command {
|
func newRemoveCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
cmd := *NewRmCommand(dockerCli)
|
cmd := *newRmCommand(dockerCli)
|
||||||
cmd.Aliases = []string{"rm", "remove"}
|
cmd.Aliases = []string{"rm", "remove"}
|
||||||
return &cmd
|
return &cmd
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ func TestRemoveForce(t *testing.T) {
|
||||||
},
|
},
|
||||||
Version: "1.36",
|
Version: "1.36",
|
||||||
})
|
})
|
||||||
cmd := NewRmCommand(cli)
|
cmd := newRmCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,13 @@ type runOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRunCommand create a new `docker run` command
|
// NewRunCommand create a new `docker run` command
|
||||||
func NewRunCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewRunCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newRunCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newRunCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var options runOptions
|
var options runOptions
|
||||||
var copts *containerOptions
|
var copts *containerOptions
|
||||||
|
|
||||||
|
|
@ -41,9 +47,9 @@ func NewRunCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
if len(args) > 1 {
|
if len(args) > 1 {
|
||||||
copts.Args = args[1:]
|
copts.Args = args[1:]
|
||||||
}
|
}
|
||||||
return runRun(cmd.Context(), dockerCli, cmd.Flags(), &options, copts)
|
return runRun(cmd.Context(), dockerCLI, cmd.Flags(), &options, copts)
|
||||||
},
|
},
|
||||||
ValidArgsFunction: completion.ImageNames(dockerCli, 1),
|
ValidArgsFunction: completion.ImageNames(dockerCLI, 1),
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"category-top": "1",
|
"category-top": "1",
|
||||||
"aliases": "docker container run, docker run",
|
"aliases": "docker container run, docker run",
|
||||||
|
|
@ -68,11 +74,11 @@ func NewRunCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
|
|
||||||
// TODO(thaJeztah): consider adding platform as "image create option" on containerOptions
|
// TODO(thaJeztah): consider adding platform as "image create option" on containerOptions
|
||||||
addPlatformFlag(flags, &options.platform)
|
addPlatformFlag(flags, &options.platform)
|
||||||
flags.BoolVar(&options.untrusted, "disable-content-trust", !dockerCli.ContentTrustEnabled(), "Skip image verification")
|
flags.BoolVar(&options.untrusted, "disable-content-trust", !dockerCLI.ContentTrustEnabled(), "Skip image verification")
|
||||||
copts = addFlags(flags)
|
copts = addFlags(flags)
|
||||||
|
|
||||||
_ = cmd.RegisterFlagCompletionFunc("detach-keys", completeDetachKeys)
|
_ = cmd.RegisterFlagCompletionFunc("detach-keys", completeDetachKeys)
|
||||||
addCompletions(cmd, dockerCli)
|
addCompletions(cmd, dockerCLI)
|
||||||
|
|
||||||
flags.VisitAll(func(flag *pflag.Flag) {
|
flags.VisitAll(func(flag *pflag.Flag) {
|
||||||
// Set a default completion function if none was set. We don't look
|
// Set a default completion function if none was set. We don't look
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ func TestRunValidateFlags(t *testing.T) {
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
cmd := NewRunCommand(test.NewFakeCli(&fakeClient{}))
|
cmd := newRunCommand(test.NewFakeCli(&fakeClient{}))
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
@ -63,7 +63,7 @@ func TestRunLabel(t *testing.T) {
|
||||||
},
|
},
|
||||||
Version: "1.36",
|
Version: "1.36",
|
||||||
})
|
})
|
||||||
cmd := NewRunCommand(fakeCLI)
|
cmd := newRunCommand(fakeCLI)
|
||||||
cmd.SetArgs([]string{"--detach=true", "--label", "foo", "busybox"})
|
cmd.SetArgs([]string{"--detach=true", "--label", "foo", "busybox"})
|
||||||
assert.NilError(t, cmd.Execute())
|
assert.NilError(t, cmd.Execute())
|
||||||
}
|
}
|
||||||
|
|
@ -110,7 +110,7 @@ func TestRunAttach(t *testing.T) {
|
||||||
fc.SetIn(streams.NewIn(tty))
|
fc.SetIn(streams.NewIn(tty))
|
||||||
})
|
})
|
||||||
|
|
||||||
cmd := NewRunCommand(fakeCLI)
|
cmd := newRunCommand(fakeCLI)
|
||||||
cmd.SetArgs([]string{"-it", "busybox"})
|
cmd.SetArgs([]string{"-it", "busybox"})
|
||||||
cmd.SilenceUsage = true
|
cmd.SilenceUsage = true
|
||||||
cmdErrC := make(chan error, 1)
|
cmdErrC := make(chan error, 1)
|
||||||
|
|
@ -187,7 +187,7 @@ func TestRunAttachTermination(t *testing.T) {
|
||||||
fc.SetIn(streams.NewIn(tty))
|
fc.SetIn(streams.NewIn(tty))
|
||||||
})
|
})
|
||||||
|
|
||||||
cmd := NewRunCommand(fakeCLI)
|
cmd := newRunCommand(fakeCLI)
|
||||||
cmd.SetArgs([]string{"-it", "busybox"})
|
cmd.SetArgs([]string{"-it", "busybox"})
|
||||||
cmd.SilenceUsage = true
|
cmd.SilenceUsage = true
|
||||||
cmdErrC := make(chan error, 1)
|
cmdErrC := make(chan error, 1)
|
||||||
|
|
@ -265,7 +265,7 @@ func TestRunPullTermination(t *testing.T) {
|
||||||
Version: "1.30",
|
Version: "1.30",
|
||||||
})
|
})
|
||||||
|
|
||||||
cmd := NewRunCommand(fakeCLI)
|
cmd := newRunCommand(fakeCLI)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs([]string{"--pull", "always", "foobar:latest"})
|
cmd.SetArgs([]string{"--pull", "always", "foobar:latest"})
|
||||||
|
|
@ -334,7 +334,7 @@ func TestRunCommandWithContentTrustErrors(t *testing.T) {
|
||||||
},
|
},
|
||||||
}, test.EnableContentTrust)
|
}, test.EnableContentTrust)
|
||||||
fakeCLI.SetNotaryClient(tc.notaryFunc)
|
fakeCLI.SetNotaryClient(tc.notaryFunc)
|
||||||
cmd := NewRunCommand(fakeCLI)
|
cmd := newRunCommand(fakeCLI)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,13 @@ type StartOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewStartCommand creates a new cobra.Command for `docker start`
|
// NewStartCommand creates a new cobra.Command for `docker start`
|
||||||
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
func NewStartCommand(dockerCli command.Cli) *cobra.Command {
|
func NewStartCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
|
return newStartCommand(dockerCli)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newStartCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
var opts StartOptions
|
var opts StartOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,13 @@ type StatsOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewStatsCommand creates a new [cobra.Command] for "docker stats".
|
// 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 {
|
func NewStatsCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newStatsCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newStatsCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
options := StatsOptions{}
|
options := StatsOptions{}
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,13 @@ type stopOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewStopCommand creates a new cobra.Command for `docker stop`
|
// NewStopCommand creates a new cobra.Command for `docker stop`
|
||||||
func NewStopCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewStopCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newStopCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newStopCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var opts stopOptions
|
var opts stopOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -34,12 +40,12 @@ func NewStopCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
}
|
}
|
||||||
opts.containers = args
|
opts.containers = args
|
||||||
opts.timeoutChanged = cmd.Flags().Changed("timeout") || cmd.Flags().Changed("time")
|
opts.timeoutChanged = cmd.Flags().Changed("timeout") || cmd.Flags().Changed("time")
|
||||||
return runStop(cmd.Context(), dockerCli, &opts)
|
return runStop(cmd.Context(), dockerCLI, &opts)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"aliases": "docker container stop, docker stop",
|
"aliases": "docker container stop, docker stop",
|
||||||
},
|
},
|
||||||
ValidArgsFunction: completion.ContainerNames(dockerCli, false),
|
ValidArgsFunction: completion.ContainerNames(dockerCLI, false),
|
||||||
}
|
}
|
||||||
|
|
||||||
flags := cmd.Flags()
|
flags := cmd.Flags()
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ func TestStop(t *testing.T) {
|
||||||
},
|
},
|
||||||
Version: "1.36",
|
Version: "1.36",
|
||||||
})
|
})
|
||||||
cmd := NewStopCommand(cli)
|
cmd := newStopCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,13 @@ type topOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTopCommand creates a new cobra.Command for `docker top`
|
// NewTopCommand creates a new cobra.Command for `docker top`
|
||||||
func NewTopCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewTopCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newTopCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newTopCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var opts topOptions
|
var opts topOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -29,12 +35,12 @@ func NewTopCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
opts.container = args[0]
|
opts.container = args[0]
|
||||||
opts.args = args[1:]
|
opts.args = args[1:]
|
||||||
return runTop(cmd.Context(), dockerCli, &opts)
|
return runTop(cmd.Context(), dockerCLI, &opts)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"aliases": "docker container top, docker top",
|
"aliases": "docker container top, docker top",
|
||||||
},
|
},
|
||||||
ValidArgsFunction: completion.ContainerNames(dockerCli, false),
|
ValidArgsFunction: completion.ContainerNames(dockerCLI, false),
|
||||||
}
|
}
|
||||||
|
|
||||||
flags := cmd.Flags()
|
flags := cmd.Flags()
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,13 @@ type unpauseOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewUnpauseCommand creates a new cobra.Command for `docker unpause`
|
// NewUnpauseCommand creates a new cobra.Command for `docker unpause`
|
||||||
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
func NewUnpauseCommand(dockerCli command.Cli) *cobra.Command {
|
func NewUnpauseCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
|
return newUnpauseCommand(dockerCli)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newUnpauseCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
var opts unpauseOptions
|
var opts unpauseOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,13 @@ type updateOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewUpdateCommand creates a new cobra.Command for `docker update`
|
// NewUpdateCommand creates a new cobra.Command for `docker update`
|
||||||
func NewUpdateCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewUpdateCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newUpdateCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newUpdateCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var options updateOptions
|
var options updateOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -47,12 +53,12 @@ func NewUpdateCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
options.containers = args
|
options.containers = args
|
||||||
options.nFlag = cmd.Flags().NFlag()
|
options.nFlag = cmd.Flags().NFlag()
|
||||||
return runUpdate(cmd.Context(), dockerCli, &options)
|
return runUpdate(cmd.Context(), dockerCLI, &options)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"aliases": "docker container update, docker update",
|
"aliases": "docker container update, docker update",
|
||||||
},
|
},
|
||||||
ValidArgsFunction: completion.ContainerNames(dockerCli, true),
|
ValidArgsFunction: completion.ContainerNames(dockerCLI, true),
|
||||||
}
|
}
|
||||||
|
|
||||||
flags := cmd.Flags()
|
flags := cmd.Flags()
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,13 @@ type waitOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWaitCommand creates a new cobra.Command for `docker wait`
|
// NewWaitCommand creates a new cobra.Command for `docker wait`
|
||||||
func NewWaitCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewWaitCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newWaitCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newWaitCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var opts waitOptions
|
var opts waitOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -25,12 +31,12 @@ func NewWaitCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
Args: cli.RequiresMinArgs(1),
|
Args: cli.RequiresMinArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
opts.containers = args
|
opts.containers = args
|
||||||
return runWait(cmd.Context(), dockerCli, &opts)
|
return runWait(cmd.Context(), dockerCLI, &opts)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"aliases": "docker container wait, docker wait",
|
"aliases": "docker container wait, docker wait",
|
||||||
},
|
},
|
||||||
ValidArgsFunction: completion.ContainerNames(dockerCli, false),
|
ValidArgsFunction: completion.ContainerNames(dockerCLI, false),
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
|
||||||
|
|
@ -7,23 +7,30 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewContextCommand returns the context cli subcommand
|
// 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{
|
cmd := &cobra.Command{
|
||||||
Use: "context",
|
Use: "context",
|
||||||
Short: "Manage contexts",
|
Short: "Manage contexts",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: command.ShowHelp(dockerCli.Err()),
|
RunE: command.ShowHelp(dockerCLI.Err()),
|
||||||
}
|
}
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
newCreateCommand(dockerCli),
|
newCreateCommand(dockerCLI),
|
||||||
newListCommand(dockerCli),
|
newListCommand(dockerCLI),
|
||||||
newUseCommand(dockerCli),
|
newUseCommand(dockerCLI),
|
||||||
newExportCommand(dockerCli),
|
newExportCommand(dockerCLI),
|
||||||
newImportCommand(dockerCli),
|
newImportCommand(dockerCLI),
|
||||||
newRemoveCommand(dockerCli),
|
newRemoveCommand(dockerCLI),
|
||||||
newUpdateCommand(dockerCli),
|
newUpdateCommand(dockerCLI),
|
||||||
newInspectCommand(dockerCli),
|
newInspectCommand(dockerCLI),
|
||||||
newShowCommand(dockerCli),
|
newShowCommand(dockerCLI),
|
||||||
)
|
)
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,14 @@ func newBuildOptions() buildOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewBuildCommand creates a new `docker build` command
|
// NewBuildCommand creates a new `docker build` command
|
||||||
func NewBuildCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewBuildCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newBuildCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// newBuildCommand creates a new `docker build` command
|
||||||
|
func newBuildCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
options := newBuildOptions()
|
options := newBuildOptions()
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ COPY data /data
|
||||||
// to support testing (ex: docker/cli#294)
|
// to support testing (ex: docker/cli#294)
|
||||||
func TestRunBuildFromGitHubSpecialCase(t *testing.T) {
|
func TestRunBuildFromGitHubSpecialCase(t *testing.T) {
|
||||||
t.Setenv("DOCKER_BUILDKIT", "0")
|
t.Setenv("DOCKER_BUILDKIT", "0")
|
||||||
cmd := NewBuildCommand(test.NewFakeCli(&fakeClient{}))
|
cmd := newBuildCommand(test.NewFakeCli(&fakeClient{}))
|
||||||
// Clone a small repo that exists so git doesn't prompt for credentials
|
// Clone a small repo that exists so git doesn't prompt for credentials
|
||||||
cmd.SetArgs([]string{"github.com/docker/for-win"})
|
cmd.SetArgs([]string{"github.com/docker/for-win"})
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
|
|
@ -146,7 +146,7 @@ func TestRunBuildFromLocalGitHubDir(t *testing.T) {
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
client := test.NewFakeCli(&fakeClient{})
|
client := test.NewFakeCli(&fakeClient{})
|
||||||
cmd := NewBuildCommand(client)
|
cmd := newBuildCommand(client)
|
||||||
cmd.SetArgs([]string{buildDir})
|
cmd.SetArgs([]string{buildDir})
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
err = cmd.Execute()
|
err = cmd.Execute()
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewImageCommand returns a cobra command for `image` subcommands
|
// NewImageCommand returns a cobra command for `image` subcommands
|
||||||
func NewImageCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewImageCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newImageCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// newImageCommand returns a cobra command for `image` subcommands
|
||||||
|
func newImageCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "image",
|
Use: "image",
|
||||||
Short: "Manage images",
|
Short: "Manage images",
|
||||||
|
|
@ -15,18 +22,18 @@ func NewImageCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
RunE: command.ShowHelp(dockerCli.Err()),
|
RunE: command.ShowHelp(dockerCli.Err()),
|
||||||
}
|
}
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
NewBuildCommand(dockerCli),
|
newBuildCommand(dockerCli),
|
||||||
NewHistoryCommand(dockerCli),
|
newHistoryCommand(dockerCli),
|
||||||
NewImportCommand(dockerCli),
|
newImportCommand(dockerCli),
|
||||||
NewLoadCommand(dockerCli),
|
newLoadCommand(dockerCli),
|
||||||
NewPullCommand(dockerCli),
|
newPullCommand(dockerCli),
|
||||||
NewPushCommand(dockerCli),
|
newPushCommand(dockerCli),
|
||||||
NewSaveCommand(dockerCli),
|
newSaveCommand(dockerCli),
|
||||||
NewTagCommand(dockerCli),
|
newTagCommand(dockerCli),
|
||||||
newListCommand(dockerCli),
|
newListCommand(dockerCli),
|
||||||
newRemoveCommand(dockerCli),
|
newImageRemoveCommand(dockerCli),
|
||||||
newInspectCommand(dockerCli),
|
newInspectCommand(dockerCli),
|
||||||
NewPruneCommand(dockerCli),
|
newPruneCommand(dockerCli),
|
||||||
)
|
)
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,14 @@ type historyOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewHistoryCommand creates a new `docker history` command
|
// NewHistoryCommand creates a new `docker history` command
|
||||||
func NewHistoryCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewHistoryCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newHistoryCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// newHistoryCommand creates a new `docker history` command
|
||||||
|
func newHistoryCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var opts historyOptions
|
var opts historyOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -34,9 +41,9 @@ func NewHistoryCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
Args: cli.ExactArgs(1),
|
Args: cli.ExactArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
opts.image = args[0]
|
opts.image = args[0]
|
||||||
return runHistory(cmd.Context(), dockerCli, opts)
|
return runHistory(cmd.Context(), dockerCLI, opts)
|
||||||
},
|
},
|
||||||
ValidArgsFunction: completion.ImageNames(dockerCli, 1),
|
ValidArgsFunction: completion.ImageNames(dockerCLI, 1),
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"aliases": "docker image history, docker history",
|
"aliases": "docker image history, docker history",
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ func TestNewHistoryCommandErrors(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
cmd := NewHistoryCommand(test.NewFakeCli(&fakeClient{imageHistoryFunc: tc.imageHistoryFunc}))
|
cmd := newHistoryCommand(test.NewFakeCli(&fakeClient{imageHistoryFunc: tc.imageHistoryFunc}))
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
@ -114,7 +114,7 @@ func TestNewHistoryCommandSuccess(t *testing.T) {
|
||||||
// printed in the current timezone
|
// printed in the current timezone
|
||||||
t.Setenv("TZ", "UTC")
|
t.Setenv("TZ", "UTC")
|
||||||
cli := test.NewFakeCli(&fakeClient{imageHistoryFunc: tc.imageHistoryFunc})
|
cli := test.NewFakeCli(&fakeClient{imageHistoryFunc: tc.imageHistoryFunc})
|
||||||
cmd := NewHistoryCommand(cli)
|
cmd := newHistoryCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,14 @@ type importOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewImportCommand creates a new `docker import` command
|
// NewImportCommand creates a new `docker import` command
|
||||||
func NewImportCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewImportCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newImportCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// newImportCommand creates a new `docker import` command
|
||||||
|
func newImportCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var options importOptions
|
var options importOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -35,7 +42,7 @@ func NewImportCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
if len(args) > 1 {
|
if len(args) > 1 {
|
||||||
options.reference = args[1]
|
options.reference = args[1]
|
||||||
}
|
}
|
||||||
return runImport(cmd.Context(), dockerCli, options)
|
return runImport(cmd.Context(), dockerCLI, options)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"aliases": "docker image import, docker import",
|
"aliases": "docker image import, docker import",
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ func TestNewImportCommandErrors(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
cmd := NewImportCommand(test.NewFakeCli(&fakeClient{imageImportFunc: tc.imageImportFunc}))
|
cmd := newImportCommand(test.NewFakeCli(&fakeClient{imageImportFunc: tc.imageImportFunc}))
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
@ -43,7 +43,7 @@ func TestNewImportCommandErrors(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNewImportCommandInvalidFile(t *testing.T) {
|
func TestNewImportCommandInvalidFile(t *testing.T) {
|
||||||
cmd := NewImportCommand(test.NewFakeCli(&fakeClient{}))
|
cmd := newImportCommand(test.NewFakeCli(&fakeClient{}))
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs([]string{"testdata/import-command-success.unexistent-file"})
|
cmd.SetArgs([]string{"testdata/import-command-success.unexistent-file"})
|
||||||
|
|
@ -99,7 +99,7 @@ func TestNewImportCommandSuccess(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
cmd := NewImportCommand(test.NewFakeCli(&fakeClient{imageImportFunc: tc.imageImportFunc}))
|
cmd := newImportCommand(test.NewFakeCli(&fakeClient{imageImportFunc: tc.imageImportFunc}))
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,14 @@ type imagesOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewImagesCommand creates a new `docker images` command
|
// NewImagesCommand creates a new `docker images` command
|
||||||
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
func NewImagesCommand(dockerCLI command.Cli) *cobra.Command {
|
func NewImagesCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newImagesCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// newImagesCommand creates a new `docker images` command
|
||||||
|
func newImagesCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
options := imagesOptions{filter: opts.NewFilterOpt()}
|
options := imagesOptions{filter: opts.NewFilterOpt()}
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -69,7 +76,7 @@ func NewImagesCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newListCommand(dockerCLI command.Cli) *cobra.Command {
|
func newListCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
cmd := *NewImagesCommand(dockerCLI)
|
cmd := *newImagesCommand(dockerCLI)
|
||||||
cmd.Aliases = []string{"list"}
|
cmd.Aliases = []string{"list"}
|
||||||
cmd.Use = "ls [OPTIONS] [REPOSITORY[:TAG]]"
|
cmd.Use = "ls [OPTIONS] [REPOSITORY[:TAG]]"
|
||||||
return &cmd
|
return &cmd
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ func TestNewImagesCommandErrors(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
cmd := NewImagesCommand(test.NewFakeCli(&fakeClient{imageListFunc: tc.imageListFunc}))
|
cmd := newImagesCommand(test.NewFakeCli(&fakeClient{imageListFunc: tc.imageListFunc}))
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
@ -85,7 +85,7 @@ func TestNewImagesCommandSuccess(t *testing.T) {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{imageListFunc: tc.imageListFunc})
|
cli := test.NewFakeCli(&fakeClient{imageListFunc: tc.imageListFunc})
|
||||||
cli.SetConfigFile(&configfile.ConfigFile{ImagesFormat: tc.imageFormat})
|
cli.SetConfigFile(&configfile.ConfigFile{ImagesFormat: tc.imageFormat})
|
||||||
cmd := NewImagesCommand(cli)
|
cmd := newImagesCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
@ -104,7 +104,7 @@ func TestNewListCommandAlias(t *testing.T) {
|
||||||
|
|
||||||
func TestNewListCommandAmbiguous(t *testing.T) {
|
func TestNewListCommandAmbiguous(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{})
|
cli := test.NewFakeCli(&fakeClient{})
|
||||||
cmd := NewImagesCommand(cli)
|
cmd := newImagesCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
|
|
||||||
// Set the Use field to mimic that the command was called as "docker images",
|
// Set the Use field to mimic that the command was called as "docker images",
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,14 @@ type loadOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLoadCommand creates a new `docker load` command
|
// NewLoadCommand creates a new `docker load` command
|
||||||
func NewLoadCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewLoadCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newLoadCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// newLoadCommand creates a new `docker load` command
|
||||||
|
func newLoadCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var opts loadOptions
|
var opts loadOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -30,7 +37,7 @@ func NewLoadCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
Short: "Load an image from a tar archive or STDIN",
|
Short: "Load an image from a tar archive or STDIN",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
return runLoad(cmd.Context(), dockerCli, opts)
|
return runLoad(cmd.Context(), dockerCLI, opts)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"aliases": "docker image load, docker load",
|
"aliases": "docker image load, docker load",
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ func TestNewLoadCommandErrors(t *testing.T) {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{imageLoadFunc: tc.imageLoadFunc})
|
cli := test.NewFakeCli(&fakeClient{imageLoadFunc: tc.imageLoadFunc})
|
||||||
cli.In().SetIsTerminal(tc.isTerminalIn)
|
cli.In().SetIsTerminal(tc.isTerminalIn)
|
||||||
cmd := NewLoadCommand(cli)
|
cmd := newLoadCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
@ -65,7 +65,7 @@ func TestNewLoadCommandErrors(t *testing.T) {
|
||||||
|
|
||||||
func TestNewLoadCommandInvalidInput(t *testing.T) {
|
func TestNewLoadCommandInvalidInput(t *testing.T) {
|
||||||
expectedError := "open *"
|
expectedError := "open *"
|
||||||
cmd := NewLoadCommand(test.NewFakeCli(&fakeClient{}))
|
cmd := newLoadCommand(test.NewFakeCli(&fakeClient{}))
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs([]string{"--input", "*"})
|
cmd.SetArgs([]string{"--input", "*"})
|
||||||
|
|
@ -117,7 +117,7 @@ func TestNewLoadCommandSuccess(t *testing.T) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{imageLoadFunc: tc.imageLoadFunc})
|
cli := test.NewFakeCli(&fakeClient{imageLoadFunc: tc.imageLoadFunc})
|
||||||
cmd := NewLoadCommand(cli)
|
cmd := newLoadCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,14 @@ type pruneOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPruneCommand returns a new cobra prune command for images
|
// NewPruneCommand returns a new cobra prune command for images
|
||||||
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 images
|
||||||
|
func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
options := pruneOptions{filter: opts.NewFilterOpt()}
|
options := pruneOptions{filter: opts.NewFilterOpt()}
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -31,14 +38,14 @@ func NewPruneCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
Short: "Remove unused images",
|
Short: "Remove unused images",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
spaceReclaimed, output, err := runPrune(cmd.Context(), dockerCli, options)
|
spaceReclaimed, output, err := runPrune(cmd.Context(), dockerCLI, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if output != "" {
|
if output != "" {
|
||||||
fmt.Fprintln(dockerCli.Out(), output)
|
fmt.Fprintln(dockerCLI.Out(), output)
|
||||||
}
|
}
|
||||||
fmt.Fprintln(dockerCli.Out(), "Total reclaimed space:", units.HumanSize(float64(spaceReclaimed)))
|
fmt.Fprintln(dockerCLI.Out(), "Total reclaimed space:", units.HumanSize(float64(spaceReclaimed)))
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{"version": "1.25"},
|
Annotations: map[string]string{"version": "1.25"},
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,14 @@ type pullOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPullCommand creates a new `docker pull` command
|
// NewPullCommand creates a new `docker pull` command
|
||||||
func NewPullCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewPullCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newPullCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// newPullCommand creates a new `docker pull` command
|
||||||
|
func newPullCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var opts pullOptions
|
var opts pullOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -36,7 +43,7 @@ func NewPullCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
Args: cli.ExactArgs(1),
|
Args: cli.ExactArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
opts.remote = args[0]
|
opts.remote = args[0]
|
||||||
return runPull(cmd.Context(), dockerCli, opts)
|
return runPull(cmd.Context(), dockerCLI, opts)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"category-top": "5",
|
"category-top": "5",
|
||||||
|
|
@ -51,7 +58,7 @@ func NewPullCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Suppress verbose output")
|
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Suppress verbose output")
|
||||||
|
|
||||||
addPlatformFlag(flags, &opts.platform)
|
addPlatformFlag(flags, &opts.platform)
|
||||||
flags.BoolVar(&opts.untrusted, "disable-content-trust", !dockerCli.ContentTrustEnabled(), "Skip image verification")
|
flags.BoolVar(&opts.untrusted, "disable-content-trust", !dockerCLI.ContentTrustEnabled(), "Skip image verification")
|
||||||
|
|
||||||
_ = cmd.RegisterFlagCompletionFunc("platform", completion.Platforms)
|
_ = cmd.RegisterFlagCompletionFunc("platform", completion.Platforms)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ func TestNewPullCommandErrors(t *testing.T) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{})
|
cli := test.NewFakeCli(&fakeClient{})
|
||||||
cmd := NewPullCommand(cli)
|
cmd := newPullCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
@ -79,7 +79,7 @@ func TestNewPullCommandSuccess(t *testing.T) {
|
||||||
return io.NopCloser(strings.NewReader("")), nil
|
return io.NopCloser(strings.NewReader("")), nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
cmd := NewPullCommand(cli)
|
cmd := newPullCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
@ -124,7 +124,7 @@ func TestNewPullCommandWithContentTrustErrors(t *testing.T) {
|
||||||
},
|
},
|
||||||
}, test.EnableContentTrust)
|
}, test.EnableContentTrust)
|
||||||
cli.SetNotaryClient(tc.notaryFunc)
|
cli.SetNotaryClient(tc.notaryFunc)
|
||||||
cmd := NewPullCommand(cli)
|
cmd := newPullCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,14 @@ type pushOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPushCommand creates a new `docker push` command
|
// NewPushCommand creates a new `docker push` command
|
||||||
func NewPushCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewPushCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newPushCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// newPushCommand creates a new `docker push` command
|
||||||
|
func newPushCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var opts pushOptions
|
var opts pushOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -45,19 +52,19 @@ func NewPushCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
Args: cli.ExactArgs(1),
|
Args: cli.ExactArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
opts.remote = args[0]
|
opts.remote = args[0]
|
||||||
return runPush(cmd.Context(), dockerCli, opts)
|
return runPush(cmd.Context(), dockerCLI, opts)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"category-top": "6",
|
"category-top": "6",
|
||||||
"aliases": "docker image push, docker push",
|
"aliases": "docker image push, docker push",
|
||||||
},
|
},
|
||||||
ValidArgsFunction: completion.ImageNames(dockerCli, 1),
|
ValidArgsFunction: completion.ImageNames(dockerCLI, 1),
|
||||||
}
|
}
|
||||||
|
|
||||||
flags := cmd.Flags()
|
flags := cmd.Flags()
|
||||||
flags.BoolVarP(&opts.all, "all-tags", "a", false, "Push all tags of an image to the repository")
|
flags.BoolVarP(&opts.all, "all-tags", "a", false, "Push all tags of an image to the repository")
|
||||||
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Suppress verbose output")
|
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Suppress verbose output")
|
||||||
flags.BoolVar(&opts.untrusted, "disable-content-trust", !dockerCli.ContentTrustEnabled(), "Skip image signing")
|
flags.BoolVar(&opts.untrusted, "disable-content-trust", !dockerCLI.ContentTrustEnabled(), "Skip image signing")
|
||||||
|
|
||||||
// Don't default to DOCKER_DEFAULT_PLATFORM env variable, always default to
|
// Don't default to DOCKER_DEFAULT_PLATFORM env variable, always default to
|
||||||
// pushing the image as-is. This also avoids forcing the platform selection
|
// pushing the image as-is. This also avoids forcing the platform selection
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ func TestNewPushCommandErrors(t *testing.T) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{imagePushFunc: tc.imagePushFunc})
|
cli := test.NewFakeCli(&fakeClient{imagePushFunc: tc.imagePushFunc})
|
||||||
cmd := NewPushCommand(cli)
|
cmd := newPushCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
@ -73,7 +73,7 @@ func TestNewPushCommandSuccess(t *testing.T) {
|
||||||
return io.NopCloser(strings.NewReader("")), nil
|
return io.NopCloser(strings.NewReader("")), nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
cmd := NewPushCommand(cli)
|
cmd := newPushCommand(cli)
|
||||||
cmd.SetOut(cli.OutBuffer())
|
cmd.SetOut(cli.OutBuffer())
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,14 @@ type removeOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRemoveCommand creates a new `docker remove` command
|
// NewRemoveCommand creates a new `docker remove` command
|
||||||
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
func NewRemoveCommand(dockerCLI command.Cli) *cobra.Command {
|
func NewRemoveCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newRemoveCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// newRemoveCommand creates a new `docker remove` command
|
||||||
|
func newRemoveCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var options removeOptions
|
var options removeOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -50,8 +57,9 @@ func NewRemoveCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func newRemoveCommand(dockerCli command.Cli) *cobra.Command {
|
// newImageRemoveCommand is a sub-command under `image` (`docker image rm`)
|
||||||
cmd := *NewRemoveCommand(dockerCli)
|
func newImageRemoveCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
|
cmd := *newRemoveCommand(dockerCli)
|
||||||
cmd.Aliases = []string{"rmi", "remove"}
|
cmd.Aliases = []string{"rmi", "remove"}
|
||||||
cmd.Use = "rm [OPTIONS] IMAGE [IMAGE...]"
|
cmd.Use = "rm [OPTIONS] IMAGE [IMAGE...]"
|
||||||
return &cmd
|
return &cmd
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ func (n notFound) Error() string {
|
||||||
func (notFound) NotFound() {}
|
func (notFound) NotFound() {}
|
||||||
|
|
||||||
func TestNewRemoveCommandAlias(t *testing.T) {
|
func TestNewRemoveCommandAlias(t *testing.T) {
|
||||||
cmd := newRemoveCommand(test.NewFakeCli(&fakeClient{}))
|
cmd := newImageRemoveCommand(test.NewFakeCli(&fakeClient{}))
|
||||||
assert.Check(t, cmd.HasAlias("rmi"))
|
assert.Check(t, cmd.HasAlias("rmi"))
|
||||||
assert.Check(t, cmd.HasAlias("remove"))
|
assert.Check(t, cmd.HasAlias("remove"))
|
||||||
assert.Check(t, !cmd.HasAlias("other"))
|
assert.Check(t, !cmd.HasAlias("other"))
|
||||||
|
|
@ -63,7 +63,7 @@ func TestNewRemoveCommandErrors(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
cmd := NewRemoveCommand(test.NewFakeCli(&fakeClient{
|
cmd := newRemoveCommand(test.NewFakeCli(&fakeClient{
|
||||||
imageRemoveFunc: tc.imageRemoveFunc,
|
imageRemoveFunc: tc.imageRemoveFunc,
|
||||||
}))
|
}))
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
|
|
@ -122,7 +122,7 @@ func TestNewRemoveCommandSuccess(t *testing.T) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{imageRemoveFunc: tc.imageRemoveFunc})
|
cli := test.NewFakeCli(&fakeClient{imageRemoveFunc: tc.imageRemoveFunc})
|
||||||
cmd := NewRemoveCommand(cli)
|
cmd := newRemoveCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,14 @@ type saveOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSaveCommand creates a new `docker save` command
|
// NewSaveCommand creates a new `docker save` command
|
||||||
func NewSaveCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewSaveCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newSaveCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// newSaveCommand creates a new `docker save` command
|
||||||
|
func newSaveCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var opts saveOptions
|
var opts saveOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -30,12 +37,12 @@ func NewSaveCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
Args: cli.RequiresMinArgs(1),
|
Args: cli.RequiresMinArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
opts.images = args
|
opts.images = args
|
||||||
return runSave(cmd.Context(), dockerCli, opts)
|
return runSave(cmd.Context(), dockerCLI, opts)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"aliases": "docker image save, docker save",
|
"aliases": "docker image save, docker save",
|
||||||
},
|
},
|
||||||
ValidArgsFunction: completion.ImageNames(dockerCli, -1),
|
ValidArgsFunction: completion.ImageNames(dockerCLI, -1),
|
||||||
}
|
}
|
||||||
|
|
||||||
flags := cmd.Flags()
|
flags := cmd.Flags()
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ func TestNewSaveCommandErrors(t *testing.T) {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{imageSaveFunc: tc.imageSaveFunc})
|
cli := test.NewFakeCli(&fakeClient{imageSaveFunc: tc.imageSaveFunc})
|
||||||
cli.Out().SetIsTerminal(tc.isTerminal)
|
cli.Out().SetIsTerminal(tc.isTerminal)
|
||||||
cmd := NewSaveCommand(cli)
|
cmd := newSaveCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
@ -114,7 +114,7 @@ func TestNewSaveCommandSuccess(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(strings.Join(tc.args, " "), func(t *testing.T) {
|
t.Run(strings.Join(tc.args, " "), func(t *testing.T) {
|
||||||
cmd := NewSaveCommand(test.NewFakeCli(&fakeClient{
|
cmd := newSaveCommand(test.NewFakeCli(&fakeClient{
|
||||||
imageSaveFunc: tc.imageSaveFunc,
|
imageSaveFunc: tc.imageSaveFunc,
|
||||||
}))
|
}))
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,14 @@ type tagOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTagCommand creates a new `docker tag` command
|
// NewTagCommand creates a new `docker tag` command
|
||||||
func NewTagCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewTagCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newTagCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// newTagCommand creates a new `docker tag` command
|
||||||
|
func newTagCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
var opts tagOptions
|
var opts tagOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ func TestCliNewTagCommandErrors(t *testing.T) {
|
||||||
}
|
}
|
||||||
expectedError := "'tag' requires 2 arguments"
|
expectedError := "'tag' requires 2 arguments"
|
||||||
for _, args := range testCases {
|
for _, args := range testCases {
|
||||||
cmd := NewTagCommand(test.NewFakeCli(&fakeClient{}))
|
cmd := newTagCommand(test.NewFakeCli(&fakeClient{}))
|
||||||
cmd.SetArgs(args)
|
cmd.SetArgs(args)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
|
|
@ -26,7 +26,7 @@ func TestCliNewTagCommandErrors(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCliNewTagCommand(t *testing.T) {
|
func TestCliNewTagCommand(t *testing.T) {
|
||||||
cmd := NewTagCommand(
|
cmd := newTagCommand(
|
||||||
test.NewFakeCli(&fakeClient{
|
test.NewFakeCli(&fakeClient{
|
||||||
imageTagFunc: func(image string, ref string) error {
|
imageTagFunc: func(image string, ref string) error {
|
||||||
assert.Check(t, is.Equal("image1", image))
|
assert.Check(t, is.Equal("image1", image))
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewManifestCommand returns a cobra command for `manifest` subcommands
|
// NewManifestCommand returns a cobra command for `manifest` subcommands
|
||||||
func NewManifestCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewManifestCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newManifestCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// newManifestCommand returns a cobra command for `manifest` subcommands
|
||||||
|
func newManifestCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
// use dockerCli as command.Cli
|
// use dockerCli as command.Cli
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "manifest COMMAND",
|
Use: "manifest COMMAND",
|
||||||
|
|
@ -18,16 +25,16 @@ func NewManifestCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
Long: manifestDescription,
|
Long: manifestDescription,
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
_, _ = fmt.Fprint(dockerCli.Err(), "\n"+cmd.UsageString())
|
_, _ = fmt.Fprint(dockerCLI.Err(), "\n"+cmd.UsageString())
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{"experimentalCLI": ""},
|
Annotations: map[string]string{"experimentalCLI": ""},
|
||||||
}
|
}
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
newCreateListCommand(dockerCli),
|
newCreateListCommand(dockerCLI),
|
||||||
newInspectCommand(dockerCli),
|
newInspectCommand(dockerCLI),
|
||||||
newAnnotateCommand(dockerCli),
|
newAnnotateCommand(dockerCLI),
|
||||||
newPushListCommand(dockerCli),
|
newPushListCommand(dockerCLI),
|
||||||
newRmManifestListCommand(dockerCli),
|
newRmManifestListCommand(dockerCLI),
|
||||||
)
|
)
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,22 +7,29 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewNetworkCommand returns a cobra command for `network` subcommands
|
// 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{
|
cmd := &cobra.Command{
|
||||||
Use: "network",
|
Use: "network",
|
||||||
Short: "Manage networks",
|
Short: "Manage networks",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: command.ShowHelp(dockerCli.Err()),
|
RunE: command.ShowHelp(dockerCLI.Err()),
|
||||||
Annotations: map[string]string{"version": "1.21"},
|
Annotations: map[string]string{"version": "1.21"},
|
||||||
}
|
}
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
newConnectCommand(dockerCli),
|
newConnectCommand(dockerCLI),
|
||||||
newCreateCommand(dockerCli),
|
newCreateCommand(dockerCLI),
|
||||||
newDisconnectCommand(dockerCli),
|
newDisconnectCommand(dockerCLI),
|
||||||
newInspectCommand(dockerCli),
|
newInspectCommand(dockerCLI),
|
||||||
newListCommand(dockerCli),
|
newListCommand(dockerCLI),
|
||||||
newRemoveCommand(dockerCli),
|
newRemoveCommand(dockerCLI),
|
||||||
NewPruneCommand(dockerCli),
|
newPruneCommand(dockerCLI),
|
||||||
)
|
)
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,14 @@ type pruneOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPruneCommand returns a new cobra prune command for networks
|
// 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()}
|
options := pruneOptions{filter: opts.NewFilterOpt()}
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -26,12 +33,12 @@ func NewPruneCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
Short: "Remove all unused networks",
|
Short: "Remove all unused networks",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if output != "" {
|
if output != "" {
|
||||||
_, _ = fmt.Fprintln(dockerCli.Out(), output)
|
_, _ = fmt.Fprintln(dockerCLI.Out(), output)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ func TestNetworkPrunePromptTermination(t *testing.T) {
|
||||||
return network.PruneReport{}, errors.New("fakeClient networkPruneFunc should not be called")
|
return network.PruneReport{}, errors.New("fakeClient networkPruneFunc should not be called")
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
cmd := NewPruneCommand(cli)
|
cmd := newPruneCommand(cli)
|
||||||
cmd.SetArgs([]string{})
|
cmd.SetArgs([]string{})
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
|
|
|
||||||
|
|
@ -12,25 +12,32 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewNodeCommand returns a cobra command for `node` subcommands
|
// NewNodeCommand returns a cobra command for `node` subcommands
|
||||||
func NewNodeCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewNodeCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newNodeCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// newNodeCommand returns a cobra command for `node` subcommands
|
||||||
|
func newNodeCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "node",
|
Use: "node",
|
||||||
Short: "Manage Swarm nodes",
|
Short: "Manage Swarm nodes",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: command.ShowHelp(dockerCli.Err()),
|
RunE: command.ShowHelp(dockerCLI.Err()),
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"version": "1.24",
|
"version": "1.24",
|
||||||
"swarm": "manager",
|
"swarm": "manager",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
newDemoteCommand(dockerCli),
|
newDemoteCommand(dockerCLI),
|
||||||
newInspectCommand(dockerCli),
|
newInspectCommand(dockerCLI),
|
||||||
newListCommand(dockerCli),
|
newListCommand(dockerCLI),
|
||||||
newPromoteCommand(dockerCli),
|
newPromoteCommand(dockerCLI),
|
||||||
newRemoveCommand(dockerCli),
|
newRemoveCommand(dockerCLI),
|
||||||
newPsCommand(dockerCli),
|
newPsCommand(dockerCLI),
|
||||||
newUpdateCommand(dockerCli),
|
newUpdateCommand(dockerCLI),
|
||||||
)
|
)
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,26 +7,33 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewPluginCommand returns a cobra command for `plugin` subcommands
|
// NewPluginCommand returns a cobra command for `plugin` subcommands
|
||||||
func NewPluginCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewPluginCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newPluginCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// newPluginCommand returns a cobra command for `plugin` subcommands
|
||||||
|
func newPluginCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "plugin",
|
Use: "plugin",
|
||||||
Short: "Manage plugins",
|
Short: "Manage plugins",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: command.ShowHelp(dockerCli.Err()),
|
RunE: command.ShowHelp(dockerCLI.Err()),
|
||||||
Annotations: map[string]string{"version": "1.25"},
|
Annotations: map[string]string{"version": "1.25"},
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
newDisableCommand(dockerCli),
|
newDisableCommand(dockerCLI),
|
||||||
newEnableCommand(dockerCli),
|
newEnableCommand(dockerCLI),
|
||||||
newInspectCommand(dockerCli),
|
newInspectCommand(dockerCLI),
|
||||||
newInstallCommand(dockerCli),
|
newInstallCommand(dockerCLI),
|
||||||
newListCommand(dockerCli),
|
newListCommand(dockerCLI),
|
||||||
newRemoveCommand(dockerCli),
|
newRemoveCommand(dockerCLI),
|
||||||
newSetCommand(dockerCli),
|
newSetCommand(dockerCLI),
|
||||||
newPushCommand(dockerCli),
|
newPushCommand(dockerCLI),
|
||||||
newCreateCommand(dockerCli),
|
newCreateCommand(dockerCLI),
|
||||||
newUpgradeCommand(dockerCli),
|
newUpgradeCommand(dockerCLI),
|
||||||
)
|
)
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,14 @@ type loginOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLoginCommand creates a new `docker login` command
|
// NewLoginCommand creates a new `docker login` command
|
||||||
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
func NewLoginCommand(dockerCLI command.Cli) *cobra.Command {
|
func NewLoginCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newLoginCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// newLoginCommand creates a new `docker login` command
|
||||||
|
func newLoginCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
var opts loginOptions
|
var opts loginOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
|
||||||
|
|
@ -584,7 +584,7 @@ func TestLoginValidateFlags(t *testing.T) {
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
cmd := NewLoginCommand(test.NewFakeCli(&fakeClient{}))
|
cmd := newLoginCommand(test.NewFakeCli(&fakeClient{}))
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewLogoutCommand creates a new `docker logout` command
|
// NewLogoutCommand creates a new `docker logout` command
|
||||||
func NewLogoutCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewLogoutCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newLogoutCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// newLogoutCommand creates a new `docker logout` command
|
||||||
|
func newLogoutCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "logout [SERVER]",
|
Use: "logout [SERVER]",
|
||||||
Short: "Log out from a registry",
|
Short: "Log out from a registry",
|
||||||
|
|
@ -24,7 +31,7 @@ func NewLogoutCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
serverAddress = args[0]
|
serverAddress = args[0]
|
||||||
}
|
}
|
||||||
return runLogout(cmd.Context(), dockerCli, serverAddress)
|
return runLogout(cmd.Context(), dockerCLI, serverAddress)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"category-top": "9",
|
"category-top": "9",
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,14 @@ type searchOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSearchCommand creates a new `docker search` command
|
// NewSearchCommand creates a new `docker search` command
|
||||||
func NewSearchCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewSearchCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newSearchCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// newSearchCommand creates a new `docker search` command
|
||||||
|
func newSearchCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
options := searchOptions{filter: opts.NewFilterOpt()}
|
options := searchOptions{filter: opts.NewFilterOpt()}
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -31,7 +38,7 @@ func NewSearchCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
Args: cli.ExactArgs(1),
|
Args: cli.ExactArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
options.term = args[0]
|
options.term = args[0]
|
||||||
return runSearch(cmd.Context(), dockerCli, options)
|
return runSearch(cmd.Context(), dockerCLI, options)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"category-top": "10",
|
"category-top": "10",
|
||||||
|
|
|
||||||
|
|
@ -9,22 +9,28 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewSecretCommand returns a cobra command for `secret` subcommands
|
// NewSecretCommand returns a cobra command for `secret` subcommands
|
||||||
func NewSecretCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewSecretCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newSecretCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newSecretCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "secret",
|
Use: "secret",
|
||||||
Short: "Manage Swarm secrets",
|
Short: "Manage Swarm secrets",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: command.ShowHelp(dockerCli.Err()),
|
RunE: command.ShowHelp(dockerCLI.Err()),
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"version": "1.25",
|
"version": "1.25",
|
||||||
"swarm": "manager",
|
"swarm": "manager",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
newSecretListCommand(dockerCli),
|
newSecretListCommand(dockerCLI),
|
||||||
newSecretCreateCommand(dockerCli),
|
newSecretCreateCommand(dockerCLI),
|
||||||
newSecretInspectCommand(dockerCli),
|
newSecretInspectCommand(dockerCLI),
|
||||||
newSecretRemoveCommand(dockerCli),
|
newSecretRemoveCommand(dockerCLI),
|
||||||
)
|
)
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,27 +7,34 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewServiceCommand returns a cobra command for `service` subcommands
|
// NewServiceCommand returns a cobra command for `service` subcommands
|
||||||
func NewServiceCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewServiceCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newServiceCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// newServiceCommand returns a cobra command for `service` subcommands
|
||||||
|
func newServiceCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "service",
|
Use: "service",
|
||||||
Short: "Manage Swarm services",
|
Short: "Manage Swarm services",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: command.ShowHelp(dockerCli.Err()),
|
RunE: command.ShowHelp(dockerCLI.Err()),
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"version": "1.24",
|
"version": "1.24",
|
||||||
"swarm": "manager",
|
"swarm": "manager",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
newCreateCommand(dockerCli),
|
newCreateCommand(dockerCLI),
|
||||||
newInspectCommand(dockerCli),
|
newInspectCommand(dockerCLI),
|
||||||
newPsCommand(dockerCli),
|
newPsCommand(dockerCLI),
|
||||||
newListCommand(dockerCli),
|
newListCommand(dockerCLI),
|
||||||
newRemoveCommand(dockerCli),
|
newRemoveCommand(dockerCLI),
|
||||||
newScaleCommand(dockerCli),
|
newScaleCommand(dockerCLI),
|
||||||
newUpdateCommand(dockerCli),
|
newUpdateCommand(dockerCLI),
|
||||||
newLogsCommand(dockerCli),
|
newLogsCommand(dockerCLI),
|
||||||
newRollbackCommand(dockerCli),
|
newRollbackCommand(dockerCLI),
|
||||||
)
|
)
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,19 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewStackCommand returns a cobra command for `stack` subcommands
|
// NewStackCommand returns a cobra command for `stack` subcommands
|
||||||
func NewStackCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewStackCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newStackCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// newStackCommand returns a cobra command for `stack` subcommands
|
||||||
|
func newStackCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "stack [OPTIONS]",
|
Use: "stack [OPTIONS]",
|
||||||
Short: "Manage Swarm stacks",
|
Short: "Manage Swarm stacks",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: command.ShowHelp(dockerCli.Err()),
|
RunE: command.ShowHelp(dockerCLI.Err()),
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"version": "1.25",
|
"version": "1.25",
|
||||||
"swarm": "manager",
|
"swarm": "manager",
|
||||||
|
|
@ -25,18 +32,18 @@ func NewStackCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
defaultHelpFunc := cmd.HelpFunc()
|
defaultHelpFunc := cmd.HelpFunc()
|
||||||
cmd.SetHelpFunc(func(c *cobra.Command, args []string) {
|
cmd.SetHelpFunc(func(c *cobra.Command, args []string) {
|
||||||
if err := cmd.Root().PersistentPreRunE(c, args); err != nil {
|
if err := cmd.Root().PersistentPreRunE(c, args); err != nil {
|
||||||
fmt.Fprintln(dockerCli.Err(), err)
|
fmt.Fprintln(dockerCLI.Err(), err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defaultHelpFunc(c, args)
|
defaultHelpFunc(c, args)
|
||||||
})
|
})
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
newDeployCommand(dockerCli),
|
newDeployCommand(dockerCLI),
|
||||||
newListCommand(dockerCli),
|
newListCommand(dockerCLI),
|
||||||
newPsCommand(dockerCli),
|
newPsCommand(dockerCLI),
|
||||||
newRemoveCommand(dockerCli),
|
newRemoveCommand(dockerCLI),
|
||||||
newServicesCommand(dockerCli),
|
newServicesCommand(dockerCLI),
|
||||||
newConfigCommand(dockerCli),
|
newConfigCommand(dockerCLI),
|
||||||
)
|
)
|
||||||
flags := cmd.PersistentFlags()
|
flags := cmd.PersistentFlags()
|
||||||
flags.String("orchestrator", "", "Orchestrator to use (swarm|all)")
|
flags.String("orchestrator", "", "Orchestrator to use (swarm|all)")
|
||||||
|
|
|
||||||
|
|
@ -8,26 +8,33 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewSwarmCommand returns a cobra command for `swarm` subcommands
|
// NewSwarmCommand returns a cobra command for `swarm` subcommands
|
||||||
func NewSwarmCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewSwarmCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newSwarmCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// newSwarmCommand returns a cobra command for `swarm` subcommands
|
||||||
|
func newSwarmCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "swarm",
|
Use: "swarm",
|
||||||
Short: "Manage Swarm",
|
Short: "Manage Swarm",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: command.ShowHelp(dockerCli.Err()),
|
RunE: command.ShowHelp(dockerCLI.Err()),
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"version": "1.24",
|
"version": "1.24",
|
||||||
"swarm": "", // swarm command itself does not require swarm to be enabled (so swarm init and join is always available on API 1.24 and up)
|
"swarm": "", // swarm command itself does not require swarm to be enabled (so swarm init and join is always available on API 1.24 and up)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
newInitCommand(dockerCli),
|
newInitCommand(dockerCLI),
|
||||||
newJoinCommand(dockerCli),
|
newJoinCommand(dockerCLI),
|
||||||
newJoinTokenCommand(dockerCli),
|
newJoinTokenCommand(dockerCLI),
|
||||||
newUnlockKeyCommand(dockerCli),
|
newUnlockKeyCommand(dockerCLI),
|
||||||
newUpdateCommand(dockerCli),
|
newUpdateCommand(dockerCLI),
|
||||||
newLeaveCommand(dockerCli),
|
newLeaveCommand(dockerCLI),
|
||||||
newUnlockCommand(dockerCli),
|
newUnlockCommand(dockerCLI),
|
||||||
newCACommand(dockerCli),
|
newCACommand(dockerCLI),
|
||||||
)
|
)
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,19 +7,26 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewSystemCommand returns a cobra command for `system` subcommands
|
// 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{
|
cmd := &cobra.Command{
|
||||||
Use: "system",
|
Use: "system",
|
||||||
Short: "Manage Docker",
|
Short: "Manage Docker",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: command.ShowHelp(dockerCli.Err()),
|
RunE: command.ShowHelp(dockerCLI.Err()),
|
||||||
}
|
}
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
NewEventsCommand(dockerCli),
|
newEventsCommand(dockerCLI),
|
||||||
NewInfoCommand(dockerCli),
|
newInfoCommand(dockerCLI),
|
||||||
newDiskUsageCommand(dockerCli),
|
newDiskUsageCommand(dockerCLI),
|
||||||
newPruneCommand(dockerCli),
|
newPruneCommand(dockerCLI),
|
||||||
newDialStdioCommand(dockerCli),
|
newDialStdioCommand(dockerCLI),
|
||||||
)
|
)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ func TestCompleteEventFilter(t *testing.T) {
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
cli := test.NewFakeCli(tc.client)
|
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.DeepEqual(t, completions, tc.expected)
|
||||||
assert.Equal(t, directive, cobra.ShellCompDirectiveNoFileComp, fmt.Sprintf("wrong directive in completion for '%s'", tc.toComplete))
|
assert.Equal(t, directive, cobra.ShellCompDirectiveNoFileComp, fmt.Sprintf("wrong directive in completion for '%s'", tc.toComplete))
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,14 @@ type eventsOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewEventsCommand creates a new cobra.Command for `docker events`
|
// 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()}
|
options := eventsOptions{filter: opts.NewFilterOpt()}
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -36,7 +43,7 @@ func NewEventsCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
Short: "Get real time events from the server",
|
Short: "Get real time events from the server",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
return runEvents(cmd.Context(), dockerCli, &options)
|
return runEvents(cmd.Context(), dockerCLI, &options)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"aliases": "docker system events, docker events",
|
"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.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.
|
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
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ func TestEventsFormat(t *testing.T) {
|
||||||
}()
|
}()
|
||||||
return messages, errs
|
return messages, errs
|
||||||
}})
|
}})
|
||||||
cmd := NewEventsCommand(cli)
|
cmd := newEventsCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,14 @@ func (i *dockerInfo) clientPlatform() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewInfoCommand creates a new cobra.Command for `docker info`
|
// 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
|
var opts infoOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -68,7 +75,7 @@ func NewInfoCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
Short: "Display system-wide information",
|
Short: "Display system-wide information",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
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{
|
Annotations: map[string]string{
|
||||||
"category-top": "12",
|
"category-top": "12",
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,14 @@ type inspectOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewInspectCommand creates a new cobra.Command for `docker inspect`
|
// 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
|
var opts inspectOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -72,7 +79,7 @@ func NewInspectCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
if cmd.Flags().Changed("type") && opts.objectType == "" {
|
if cmd.Flags().Changed("type") && opts.objectType == "" {
|
||||||
return fmt.Errorf(`type is empty: must be one of "%s"`, strings.Join(allTypes, `", "`))
|
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?)
|
// TODO(thaJeztah): should we consider adding completion for common object-types? (images, containers?)
|
||||||
ValidArgsFunction: completion.NoComplete,
|
ValidArgsFunction: completion.NoComplete,
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ func TestInspectValidateFlagsAndArgs(t *testing.T) {
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(tc.name, func(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.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,14 @@ func newClientVersion(contextName string, dockerCli command.Cli) clientVersion {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewVersionCommand creates a new cobra.Command for `docker version`
|
// 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
|
var opts versionOptions
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -117,7 +124,7 @@ func NewVersionCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
Short: "Show the Docker version information",
|
Short: "Show the Docker version information",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
return runVersion(cmd.Context(), dockerCli, &opts)
|
return runVersion(cmd.Context(), dockerCLI, &opts)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"category-top": "10",
|
"category-top": "10",
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ func TestVersionWithoutServer(t *testing.T) {
|
||||||
return types.Version{}, errors.New("no server")
|
return types.Version{}, errors.New("no server")
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
cmd := NewVersionCommand(cli)
|
cmd := newVersionCommand(cli)
|
||||||
cmd.SetArgs([]string{})
|
cmd.SetArgs([]string{})
|
||||||
cmd.SetOut(cli.Err())
|
cmd.SetOut(cli.Err())
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
|
|
|
||||||
|
|
@ -7,19 +7,25 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewTrustCommand returns a cobra command for `trust` subcommands
|
// NewTrustCommand returns a cobra command for `trust` subcommands
|
||||||
func NewTrustCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewTrustCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newTrustCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newTrustCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "trust",
|
Use: "trust",
|
||||||
Short: "Manage trust on Docker images",
|
Short: "Manage trust on Docker images",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: command.ShowHelp(dockerCli.Err()),
|
RunE: command.ShowHelp(dockerCLI.Err()),
|
||||||
}
|
}
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
newRevokeCommand(dockerCli),
|
newRevokeCommand(dockerCLI),
|
||||||
newSignCommand(dockerCli),
|
newSignCommand(dockerCLI),
|
||||||
newTrustKeyCommand(dockerCli),
|
newTrustKeyCommand(dockerCLI),
|
||||||
newTrustSignerCommand(dockerCli),
|
newTrustSignerCommand(dockerCLI),
|
||||||
newInspectCommand(dockerCli),
|
newInspectCommand(dockerCLI),
|
||||||
)
|
)
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,21 +7,28 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewVolumeCommand returns a cobra command for `volume` subcommands
|
// NewVolumeCommand returns a cobra command for `volume` subcommands
|
||||||
func NewVolumeCommand(dockerCli command.Cli) *cobra.Command {
|
//
|
||||||
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
||||||
|
func NewVolumeCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
|
return newVolumeCommand(dockerCLI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// newVolumeCommand returns a cobra command for `volume` subcommands
|
||||||
|
func newVolumeCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "volume COMMAND",
|
Use: "volume COMMAND",
|
||||||
Short: "Manage volumes",
|
Short: "Manage volumes",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: command.ShowHelp(dockerCli.Err()),
|
RunE: command.ShowHelp(dockerCLI.Err()),
|
||||||
Annotations: map[string]string{"version": "1.21"},
|
Annotations: map[string]string{"version": "1.21"},
|
||||||
}
|
}
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
newCreateCommand(dockerCli),
|
newCreateCommand(dockerCLI),
|
||||||
newInspectCommand(dockerCli),
|
newInspectCommand(dockerCLI),
|
||||||
newListCommand(dockerCli),
|
newListCommand(dockerCLI),
|
||||||
newRemoveCommand(dockerCli),
|
newRemoveCommand(dockerCLI),
|
||||||
NewPruneCommand(dockerCli),
|
newPruneCommand(dockerCLI),
|
||||||
newUpdateCommand(dockerCli),
|
newUpdateCommand(dockerCLI),
|
||||||
)
|
)
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,14 @@ type pruneOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPruneCommand returns a new cobra prune command for volumes
|
// NewPruneCommand returns a new cobra prune command for volumes
|
||||||
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 volumes
|
||||||
|
func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
|
||||||
options := pruneOptions{filter: opts.NewFilterOpt()}
|
options := pruneOptions{filter: opts.NewFilterOpt()}
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
@ -30,14 +37,14 @@ func NewPruneCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
Short: "Remove unused local volumes",
|
Short: "Remove unused local volumes",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
spaceReclaimed, output, err := runPrune(cmd.Context(), dockerCli, options)
|
spaceReclaimed, output, err := runPrune(cmd.Context(), dockerCLI, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if output != "" {
|
if output != "" {
|
||||||
fmt.Fprintln(dockerCli.Out(), output)
|
fmt.Fprintln(dockerCLI.Out(), output)
|
||||||
}
|
}
|
||||||
fmt.Fprintln(dockerCli.Out(), "Total reclaimed space:", units.HumanSize(float64(spaceReclaimed)))
|
fmt.Fprintln(dockerCLI.Out(), "Total reclaimed space:", units.HumanSize(float64(spaceReclaimed)))
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{"version": "1.25"},
|
Annotations: map[string]string{"version": "1.25"},
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ func TestVolumePruneErrors(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
cmd := NewPruneCommand(
|
cmd := newPruneCommand(
|
||||||
test.NewFakeCli(&fakeClient{
|
test.NewFakeCli(&fakeClient{
|
||||||
volumePruneFunc: tc.volumePruneFunc,
|
volumePruneFunc: tc.volumePruneFunc,
|
||||||
}),
|
}),
|
||||||
|
|
@ -105,7 +105,7 @@ func TestVolumePruneSuccess(t *testing.T) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{volumePruneFunc: tc.volumePruneFunc})
|
cli := test.NewFakeCli(&fakeClient{volumePruneFunc: tc.volumePruneFunc})
|
||||||
cmd := NewPruneCommand(cli)
|
cmd := newPruneCommand(cli)
|
||||||
if tc.input != "" {
|
if tc.input != "" {
|
||||||
cli.SetIn(streams.NewIn(io.NopCloser(strings.NewReader(tc.input))))
|
cli.SetIn(streams.NewIn(io.NopCloser(strings.NewReader(tc.input))))
|
||||||
}
|
}
|
||||||
|
|
@ -135,7 +135,7 @@ func TestVolumePruneForce(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{
|
cli := test.NewFakeCli(&fakeClient{
|
||||||
volumePruneFunc: tc.volumePruneFunc,
|
volumePruneFunc: tc.volumePruneFunc,
|
||||||
})
|
})
|
||||||
cmd := NewPruneCommand(cli)
|
cmd := newPruneCommand(cli)
|
||||||
cmd.Flags().Set("force", "true")
|
cmd.Flags().Set("force", "true")
|
||||||
assert.NilError(t, cmd.Execute())
|
assert.NilError(t, cmd.Execute())
|
||||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("volume-prune.%s.golden", tc.name))
|
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("volume-prune.%s.golden", tc.name))
|
||||||
|
|
@ -152,7 +152,7 @@ func TestVolumePrunePromptYes(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
cli.SetIn(streams.NewIn(io.NopCloser(strings.NewReader(input))))
|
cli.SetIn(streams.NewIn(io.NopCloser(strings.NewReader(input))))
|
||||||
cmd := NewPruneCommand(cli)
|
cmd := newPruneCommand(cli)
|
||||||
cmd.SetArgs([]string{})
|
cmd.SetArgs([]string{})
|
||||||
assert.NilError(t, cmd.Execute())
|
assert.NilError(t, cmd.Execute())
|
||||||
golden.Assert(t, cli.OutBuffer().String(), "volume-prune-yes.golden")
|
golden.Assert(t, cli.OutBuffer().String(), "volume-prune-yes.golden")
|
||||||
|
|
@ -170,7 +170,7 @@ func TestVolumePrunePromptNo(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
cli.SetIn(streams.NewIn(io.NopCloser(strings.NewReader(input))))
|
cli.SetIn(streams.NewIn(io.NopCloser(strings.NewReader(input))))
|
||||||
cmd := NewPruneCommand(cli)
|
cmd := newPruneCommand(cli)
|
||||||
cmd.SetArgs([]string{})
|
cmd.SetArgs([]string{})
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
|
|
@ -199,7 +199,7 @@ func TestVolumePrunePromptTerminate(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
cmd := NewPruneCommand(cli)
|
cmd := newPruneCommand(cli)
|
||||||
cmd.SetArgs([]string{})
|
cmd.SetArgs([]string{})
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue