mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
make node ps default to self in swarm node
Signed-off-by: allencloud <allen.sun@daocloud.io>
This commit is contained in:
parent
92da332638
commit
b13f5dfd13
9 changed files with 21 additions and 16 deletions
|
@ -28,7 +28,7 @@ func NewNodeCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|||
newListCommand(dockerCli),
|
||||
newPromoteCommand(dockerCli),
|
||||
newRemoveCommand(dockerCli),
|
||||
newPSCommand(dockerCli),
|
||||
newPsCommand(dockerCli),
|
||||
newUpdateCommand(dockerCli),
|
||||
)
|
||||
return cmd
|
||||
|
|
|
@ -19,16 +19,21 @@ type psOptions struct {
|
|||
filter opts.FilterOpt
|
||||
}
|
||||
|
||||
func newPSCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||
func newPsCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||
opts := psOptions{filter: opts.NewFilterOpt()}
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "ps [OPTIONS] self|NODE",
|
||||
Short: "List tasks running on a node",
|
||||
Args: cli.ExactArgs(1),
|
||||
Use: "ps [OPTIONS] [NODE]",
|
||||
Short: "List tasks running on a node, defaults to current node",
|
||||
Args: cli.RequiresRangeArgs(0, 1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
opts.nodeID = args[0]
|
||||
return runPS(dockerCli, opts)
|
||||
opts.nodeID = "self"
|
||||
|
||||
if len(args) != 0 {
|
||||
opts.nodeID = args[0]
|
||||
}
|
||||
|
||||
return runPs(dockerCli, opts)
|
||||
},
|
||||
}
|
||||
flags := cmd.Flags()
|
||||
|
@ -39,7 +44,7 @@ func newPSCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func runPS(dockerCli *client.DockerCli, opts psOptions) error {
|
||||
func runPs(dockerCli *client.DockerCli, opts psOptions) error {
|
||||
client := dockerCli.Client()
|
||||
ctx := context.Background()
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ func NewServiceCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|||
cmd.AddCommand(
|
||||
newCreateCommand(dockerCli),
|
||||
newInspectCommand(dockerCli),
|
||||
newPSCommand(dockerCli),
|
||||
newPsCommand(dockerCli),
|
||||
newListCommand(dockerCli),
|
||||
newRemoveCommand(dockerCli),
|
||||
newScaleCommand(dockerCli),
|
||||
|
|
|
@ -20,7 +20,7 @@ type psOptions struct {
|
|||
filter opts.FilterOpt
|
||||
}
|
||||
|
||||
func newPSCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||
func newPsCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||
opts := psOptions{filter: opts.NewFilterOpt()}
|
||||
|
||||
cmd := &cobra.Command{
|
||||
|
|
|
@ -25,7 +25,7 @@ func NewStackCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|||
newDeployCommand(dockerCli),
|
||||
newRemoveCommand(dockerCli),
|
||||
newServicesCommand(dockerCli),
|
||||
newPSCommand(dockerCli),
|
||||
newPsCommand(dockerCli),
|
||||
)
|
||||
return cmd
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ type psOptions struct {
|
|||
noResolve bool
|
||||
}
|
||||
|
||||
func newPSCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||
func newPsCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||
opts := psOptions{filter: opts.NewFilterOpt()}
|
||||
|
||||
cmd := &cobra.Command{
|
||||
|
|
|
@ -792,7 +792,7 @@ __docker_node_commands() {
|
|||
"ls:List nodes in the swarm"
|
||||
"promote:Promote a node as manager in the swarm"
|
||||
"rm:Remove one or more nodes from the swarm"
|
||||
"ps:List tasks running on a node"
|
||||
"ps:List tasks running on a node, defaults to current node"
|
||||
"update:Update a node"
|
||||
)
|
||||
_describe -t docker-node-commands "docker node command" _docker_node_subcommands
|
||||
|
|
|
@ -115,7 +115,7 @@ read the [`dockerd`](dockerd.md) reference page.
|
|||
| [node demote](node_demote.md) | Demotes an existing manager so that it is no longer a manager |
|
||||
| [node inspect](node_inspect.md) | Inspect a node in the swarm |
|
||||
| [node update](node_update.md) | Update attributes for a node |
|
||||
| [node ps](node_ps.md) | List tasks running on a node |
|
||||
| [node ps](node_ps.md) | List tasks running on a node |
|
||||
| [node ls](node_ls.md) | List nodes in the swarm |
|
||||
| [node rm](node_rm.md) | Remove one or more nodes from the swarm |
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ parent = "smn_cli"
|
|||
# node ps
|
||||
|
||||
```markdown
|
||||
Usage: docker node ps [OPTIONS] self|NODE
|
||||
Usage: docker node ps [OPTIONS] [NODE]
|
||||
|
||||
List tasks running on a node
|
||||
List tasks running on a node, defaults to current node.
|
||||
|
||||
Options:
|
||||
-a, --all Display all instances
|
||||
|
|
Loading…
Reference in a new issue