mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add support for --type=secret
in docker inspect
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
dc1f036772
commit
71129f6be6
3 changed files with 21 additions and 4 deletions
|
@ -4,13 +4,12 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"golang.org/x/net/context"
|
|
||||||
|
|
||||||
"github.com/docker/docker/cli"
|
"github.com/docker/docker/cli"
|
||||||
"github.com/docker/docker/cli/command"
|
"github.com/docker/docker/cli/command"
|
||||||
"github.com/docker/docker/cli/command/inspect"
|
"github.com/docker/docker/cli/command/inspect"
|
||||||
apiclient "github.com/docker/docker/client"
|
apiclient "github.com/docker/docker/client"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
type inspectOptions struct {
|
type inspectOptions struct {
|
||||||
|
@ -45,7 +44,7 @@ func NewInspectCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||||
func runInspect(dockerCli *command.DockerCli, opts inspectOptions) error {
|
func runInspect(dockerCli *command.DockerCli, opts inspectOptions) error {
|
||||||
var elementSearcher inspect.GetRefFunc
|
var elementSearcher inspect.GetRefFunc
|
||||||
switch opts.inspectType {
|
switch opts.inspectType {
|
||||||
case "", "container", "image", "node", "network", "service", "volume", "task", "plugin":
|
case "", "container", "image", "node", "network", "service", "volume", "task", "plugin", "secret":
|
||||||
elementSearcher = inspectAll(context.Background(), dockerCli, opts.size, opts.inspectType)
|
elementSearcher = inspectAll(context.Background(), dockerCli, opts.size, opts.inspectType)
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("%q is not a valid value for --type", opts.inspectType)
|
return fmt.Errorf("%q is not a valid value for --type", opts.inspectType)
|
||||||
|
@ -101,6 +100,12 @@ func inspectPlugin(ctx context.Context, dockerCli *command.DockerCli) inspect.Ge
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func inspectSecret(ctx context.Context, dockerCli *command.DockerCli) inspect.GetRefFunc {
|
||||||
|
return func(ref string) (interface{}, []byte, error) {
|
||||||
|
return dockerCli.Client().SecretInspectWithRaw(ctx, ref)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func inspectAll(ctx context.Context, dockerCli *command.DockerCli, getSize bool, typeConstraint string) inspect.GetRefFunc {
|
func inspectAll(ctx context.Context, dockerCli *command.DockerCli, getSize bool, typeConstraint string) inspect.GetRefFunc {
|
||||||
var inspectAutodetect = []struct {
|
var inspectAutodetect = []struct {
|
||||||
objectType string
|
objectType string
|
||||||
|
@ -144,6 +149,11 @@ func inspectAll(ctx context.Context, dockerCli *command.DockerCli, getSize bool,
|
||||||
objectType: "plugin",
|
objectType: "plugin",
|
||||||
objectInspector: inspectPlugin(ctx, dockerCli),
|
objectInspector: inspectPlugin(ctx, dockerCli),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
objectType: "secret",
|
||||||
|
isSwarmObject: true,
|
||||||
|
objectInspector: inspectSecret(ctx, dockerCli),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// isSwarmManager does an Info API call to verify that the daemon is
|
// isSwarmManager does an Info API call to verify that the daemon is
|
||||||
|
|
|
@ -2511,7 +2511,7 @@ _docker_inspect() {
|
||||||
;;
|
;;
|
||||||
--type)
|
--type)
|
||||||
if [ -z "$preselected_type" ] ; then
|
if [ -z "$preselected_type" ] ; then
|
||||||
COMPREPLY=( $( compgen -W "container image network node plugin service volume" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "container image network node plugin secret service volume" -- "$cur" ) )
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -2534,6 +2534,7 @@ _docker_inspect() {
|
||||||
$(__docker_networks)
|
$(__docker_networks)
|
||||||
$(__docker_nodes)
|
$(__docker_nodes)
|
||||||
$(__docker_plugins_installed)
|
$(__docker_plugins_installed)
|
||||||
|
$(__docker_secrets)
|
||||||
$(__docker_services)
|
$(__docker_services)
|
||||||
$(__docker_volumes)
|
$(__docker_volumes)
|
||||||
" -- "$cur" ) )
|
" -- "$cur" ) )
|
||||||
|
@ -2553,6 +2554,9 @@ _docker_inspect() {
|
||||||
plugin)
|
plugin)
|
||||||
__docker_complete_plugins_installed
|
__docker_complete_plugins_installed
|
||||||
;;
|
;;
|
||||||
|
secret)
|
||||||
|
__docker_complete_secrets
|
||||||
|
;;
|
||||||
service)
|
service)
|
||||||
__docker_complete_services
|
__docker_complete_services
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -2713,6 +2713,8 @@ __docker_subcommand() {
|
||||||
__docker_complete_nodes && ret=0
|
__docker_complete_nodes && ret=0
|
||||||
elif [[ ${words[(r)--type=plugin]} == --type=plugin ]]; then
|
elif [[ ${words[(r)--type=plugin]} == --type=plugin ]]; then
|
||||||
__docker_complete_plugins && ret=0
|
__docker_complete_plugins && ret=0
|
||||||
|
elif [[ ${words[(r)--type=service]} == --type=secrets ]]; then
|
||||||
|
__docker_complete_secrets && ret=0
|
||||||
elif [[ ${words[(r)--type=service]} == --type=service ]]; then
|
elif [[ ${words[(r)--type=service]} == --type=service ]]; then
|
||||||
__docker_complete_services && ret=0
|
__docker_complete_services && ret=0
|
||||||
elif [[ ${words[(r)--type=volume]} == --type=volume ]]; then
|
elif [[ ${words[(r)--type=volume]} == --type=volume ]]; then
|
||||||
|
@ -2723,6 +2725,7 @@ __docker_subcommand() {
|
||||||
__docker_complete_networks
|
__docker_complete_networks
|
||||||
__docker_complete_nodes
|
__docker_complete_nodes
|
||||||
__docker_complete_plugins
|
__docker_complete_plugins
|
||||||
|
__docker_complete_secrets
|
||||||
__docker_complete_services
|
__docker_complete_services
|
||||||
__docker_complete_volumes && ret=0
|
__docker_complete_volumes && ret=0
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Reference in a new issue