2016-09-08 13:11:39 -04:00
|
|
|
package commands
|
2016-06-23 11:25:51 -04:00
|
|
|
|
|
|
|
import (
|
2016-09-12 11:37:00 -04:00
|
|
|
"os"
|
|
|
|
|
2016-09-08 13:11:39 -04:00
|
|
|
"github.com/docker/docker/cli/command"
|
2016-05-12 10:52:00 -04:00
|
|
|
"github.com/docker/docker/cli/command/checkpoint"
|
2016-09-08 13:11:39 -04:00
|
|
|
"github.com/docker/docker/cli/command/container"
|
|
|
|
"github.com/docker/docker/cli/command/image"
|
|
|
|
"github.com/docker/docker/cli/command/network"
|
|
|
|
"github.com/docker/docker/cli/command/node"
|
|
|
|
"github.com/docker/docker/cli/command/plugin"
|
|
|
|
"github.com/docker/docker/cli/command/registry"
|
2016-10-19 12:22:02 -04:00
|
|
|
"github.com/docker/docker/cli/command/secret"
|
2016-09-08 13:11:39 -04:00
|
|
|
"github.com/docker/docker/cli/command/service"
|
|
|
|
"github.com/docker/docker/cli/command/stack"
|
|
|
|
"github.com/docker/docker/cli/command/swarm"
|
|
|
|
"github.com/docker/docker/cli/command/system"
|
|
|
|
"github.com/docker/docker/cli/command/volume"
|
2016-06-23 11:25:51 -04:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2016-09-08 14:54:01 -04:00
|
|
|
// AddCommands adds all the commands from cli/command to the root command
|
2016-09-08 13:11:39 -04:00
|
|
|
func AddCommands(cmd *cobra.Command, dockerCli *command.DockerCli) {
|
2016-06-23 11:25:51 -04:00
|
|
|
cmd.AddCommand(
|
2016-12-01 11:08:24 -05:00
|
|
|
// checkpoint
|
|
|
|
checkpoint.NewCheckpointCommand(dockerCli),
|
|
|
|
|
|
|
|
// container
|
2016-06-23 13:03:40 -04:00
|
|
|
container.NewContainerCommand(dockerCli),
|
2016-06-23 11:25:51 -04:00
|
|
|
container.NewRunCommand(dockerCli),
|
2016-12-01 11:08:24 -05:00
|
|
|
|
|
|
|
// image
|
|
|
|
image.NewImageCommand(dockerCli),
|
2016-06-23 11:25:51 -04:00
|
|
|
image.NewBuildCommand(dockerCli),
|
2016-12-01 11:08:24 -05:00
|
|
|
|
|
|
|
// node
|
|
|
|
node.NewNodeCommand(dockerCli),
|
|
|
|
|
|
|
|
// network
|
2016-06-23 11:25:51 -04:00
|
|
|
network.NewNetworkCommand(dockerCli),
|
2016-12-01 11:08:24 -05:00
|
|
|
|
|
|
|
// plugin
|
|
|
|
plugin.NewPluginCommand(dockerCli),
|
|
|
|
|
|
|
|
// registry
|
2016-06-23 11:25:51 -04:00
|
|
|
registry.NewLoginCommand(dockerCli),
|
|
|
|
registry.NewLogoutCommand(dockerCli),
|
2016-08-29 09:59:41 -04:00
|
|
|
registry.NewSearchCommand(dockerCli),
|
2016-12-01 11:08:24 -05:00
|
|
|
|
|
|
|
// secret
|
|
|
|
secret.NewSecretCommand(dockerCli),
|
|
|
|
|
|
|
|
// service
|
|
|
|
service.NewServiceCommand(dockerCli),
|
|
|
|
|
|
|
|
// system
|
|
|
|
system.NewSystemCommand(dockerCli),
|
2016-06-23 11:25:51 -04:00
|
|
|
system.NewVersionCommand(dockerCli),
|
2016-12-01 11:08:24 -05:00
|
|
|
|
|
|
|
// stack
|
|
|
|
stack.NewStackCommand(dockerCli),
|
|
|
|
stack.NewTopLevelDeployCommand(dockerCli),
|
|
|
|
|
|
|
|
// swarm
|
|
|
|
swarm.NewSwarmCommand(dockerCli),
|
|
|
|
|
|
|
|
// volume
|
2016-06-23 11:25:51 -04:00
|
|
|
volume.NewVolumeCommand(dockerCli),
|
2016-12-01 11:08:24 -05:00
|
|
|
|
|
|
|
// legacy commands may be hidden
|
|
|
|
hide(system.NewEventsCommand(dockerCli)),
|
2016-09-19 13:38:58 -04:00
|
|
|
hide(system.NewInfoCommand(dockerCli)),
|
2016-12-01 11:08:24 -05:00
|
|
|
hide(system.NewInspectCommand(dockerCli)),
|
2016-06-23 13:03:40 -04:00
|
|
|
hide(container.NewAttachCommand(dockerCli)),
|
|
|
|
hide(container.NewCommitCommand(dockerCli)),
|
|
|
|
hide(container.NewCopyCommand(dockerCli)),
|
|
|
|
hide(container.NewCreateCommand(dockerCli)),
|
|
|
|
hide(container.NewDiffCommand(dockerCli)),
|
|
|
|
hide(container.NewExecCommand(dockerCli)),
|
|
|
|
hide(container.NewExportCommand(dockerCli)),
|
|
|
|
hide(container.NewKillCommand(dockerCli)),
|
|
|
|
hide(container.NewLogsCommand(dockerCli)),
|
|
|
|
hide(container.NewPauseCommand(dockerCli)),
|
|
|
|
hide(container.NewPortCommand(dockerCli)),
|
|
|
|
hide(container.NewPsCommand(dockerCli)),
|
|
|
|
hide(container.NewRenameCommand(dockerCli)),
|
|
|
|
hide(container.NewRestartCommand(dockerCli)),
|
|
|
|
hide(container.NewRmCommand(dockerCli)),
|
|
|
|
hide(container.NewStartCommand(dockerCli)),
|
|
|
|
hide(container.NewStatsCommand(dockerCli)),
|
|
|
|
hide(container.NewStopCommand(dockerCli)),
|
|
|
|
hide(container.NewTopCommand(dockerCli)),
|
|
|
|
hide(container.NewUnpauseCommand(dockerCli)),
|
|
|
|
hide(container.NewUpdateCommand(dockerCli)),
|
|
|
|
hide(container.NewWaitCommand(dockerCli)),
|
|
|
|
hide(image.NewHistoryCommand(dockerCli)),
|
|
|
|
hide(image.NewImagesCommand(dockerCli)),
|
|
|
|
hide(image.NewImportCommand(dockerCli)),
|
|
|
|
hide(image.NewLoadCommand(dockerCli)),
|
|
|
|
hide(image.NewPullCommand(dockerCli)),
|
|
|
|
hide(image.NewPushCommand(dockerCli)),
|
|
|
|
hide(image.NewRemoveCommand(dockerCli)),
|
|
|
|
hide(image.NewSaveCommand(dockerCli)),
|
|
|
|
hide(image.NewTagCommand(dockerCli)),
|
2016-06-23 11:25:51 -04:00
|
|
|
)
|
2016-10-06 10:09:54 -04:00
|
|
|
|
2016-06-23 11:25:51 -04:00
|
|
|
}
|
2016-06-23 13:03:40 -04:00
|
|
|
|
|
|
|
func hide(cmd *cobra.Command) *cobra.Command {
|
2016-12-01 11:08:24 -05:00
|
|
|
// If the environment variable with name "DOCKER_HIDE_LEGACY_COMMANDS" is not empty,
|
|
|
|
// these legacy commands (such as `docker ps`, `docker exec`, etc)
|
|
|
|
// will not be shown in output console.
|
2016-09-12 11:37:00 -04:00
|
|
|
if os.Getenv("DOCKER_HIDE_LEGACY_COMMANDS") == "" {
|
|
|
|
return cmd
|
|
|
|
}
|
2016-06-23 13:03:40 -04:00
|
|
|
cmdCopy := *cmd
|
|
|
|
cmdCopy.Hidden = true
|
|
|
|
cmdCopy.Aliases = []string{}
|
|
|
|
return &cmdCopy
|
|
|
|
}
|