mirror of https://github.com/docker/cli.git
Add `--format` flag for `docker plugin ls`
This fix tries to address the enhancement discussed in 28735 to add `--format` for the output of `docker plugin ls`. This fix 1. Add `--format` and `--quiet` flags to `docker plugin ls` 2. Convert the current implementation to use `formatter`, consistent with other docker list commands. 3. Add `pluginsFormat` for config.json. Related docs has been updated. Several unit tests have been added to cover the changes. This fix is related to 28708 and 28735. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
parent
e65d4d2907
commit
d36dd6541a
|
@ -131,6 +131,12 @@ Docker's client uses this property. If this property is not set, the client
|
|||
falls back to the default table format. For a list of supported formatting
|
||||
directives, see the [**Formatting** section in the `docker images` documentation](images.md)
|
||||
|
||||
The property `pluginsFormat` specifies the default format for `docker plugin ls` output.
|
||||
When the `--format` flag is not provided with the `docker plugin ls` command,
|
||||
Docker's client uses this property. If this property is not set, the client
|
||||
falls back to the default table format. For a list of supported formatting
|
||||
directives, see the [**Formatting** section in the `docker plugin ls` documentation](plugin_ls.md)
|
||||
|
||||
The property `serviceInspectFormat` specifies the default format for `docker
|
||||
service inspect` output. When the `--format` flag is not provided with the
|
||||
`docker service inspect` command, Docker's client uses this property. If this
|
||||
|
@ -186,6 +192,7 @@ Following is a sample `config.json` file:
|
|||
},
|
||||
"psFormat": "table {{.ID}}\\t{{.Image}}\\t{{.Command}}\\t{{.Labels}}",
|
||||
"imagesFormat": "table {{.ID}}\\t{{.Repository}}\\t{{.Tag}}\\t{{.CreatedAt}}",
|
||||
"pluginsFormat": "table {{.ID}}\t{{.Name}}\t{{.Enabled}}",
|
||||
"statsFormat": "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}",
|
||||
"serviceInspectFormat": "pretty",
|
||||
"detachKeys": "ctrl-e,e",
|
||||
|
|
|
@ -24,8 +24,10 @@ Aliases:
|
|||
ls, list
|
||||
|
||||
Options:
|
||||
--help Print usage
|
||||
--no-trunc Don't truncate output
|
||||
--format string Pretty-print plugins using a Go template
|
||||
--help Print usage
|
||||
--no-trunc Don't truncate output
|
||||
-q, --quiet Only display plugin IDs
|
||||
```
|
||||
|
||||
Lists all the plugins that are currently installed. You can install plugins
|
||||
|
@ -40,6 +42,32 @@ ID NAME TAG DESCRIP
|
|||
69553ca1d123 tiborvass/sample-volume-plugin latest A test plugin for Docker true
|
||||
```
|
||||
|
||||
## Formatting
|
||||
|
||||
The formatting options (`--format`) pretty-prints plugins output
|
||||
using a Go template.
|
||||
|
||||
Valid placeholders for the Go template are listed below:
|
||||
|
||||
Placeholder | Description
|
||||
---------------|------------------------------------------------------------------------------------------
|
||||
`.ID` | Plugin ID
|
||||
`.Name` | Plugin name
|
||||
`.Description` | Plugin description
|
||||
`.Enabled` | Whether plugin is enabled or not
|
||||
|
||||
When using the `--format` option, the `plugin ls` command will either
|
||||
output the data exactly as the template declares or, when using the
|
||||
`table` directive, includes column headers as well.
|
||||
|
||||
The following example uses a template without headers and outputs the
|
||||
`ID` and `Name` entries separated by a colon for all plugins:
|
||||
|
||||
```bash
|
||||
$ docker plugin ls --format "{{.ID}}: {{.Name}}"
|
||||
4be01827a72e: tiborvass/no-remove
|
||||
```
|
||||
|
||||
## Related information
|
||||
|
||||
* [plugin create](plugin_create.md)
|
||||
|
|
Loading…
Reference in New Issue