github.com/openshift/moby-moby@v1.13.2-0.20170601211448-f5ec1e2936dc/cli/command/secret/inspect.go (about) 1 package secret 2 3 import ( 4 "github.com/docker/docker/cli" 5 "github.com/docker/docker/cli/command" 6 "github.com/docker/docker/cli/command/inspect" 7 "github.com/spf13/cobra" 8 "golang.org/x/net/context" 9 ) 10 11 type inspectOptions struct { 12 names []string 13 format string 14 } 15 16 func newSecretInspectCommand(dockerCli *command.DockerCli) *cobra.Command { 17 opts := inspectOptions{} 18 cmd := &cobra.Command{ 19 Use: "inspect [OPTIONS] SECRET [SECRET...]", 20 Short: "Display detailed information on one or more secrets", 21 Args: cli.RequiresMinArgs(1), 22 RunE: func(cmd *cobra.Command, args []string) error { 23 opts.names = args 24 return runSecretInspect(dockerCli, opts) 25 }, 26 } 27 28 cmd.Flags().StringVarP(&opts.format, "format", "f", "", "Format the output using the given Go template") 29 return cmd 30 } 31 32 func runSecretInspect(dockerCli *command.DockerCli, opts inspectOptions) error { 33 client := dockerCli.Client() 34 ctx := context.Background() 35 36 ids, err := getCliRequestedSecretIDs(ctx, client, opts.names) 37 if err != nil { 38 return err 39 } 40 getRef := func(id string) (interface{}, []byte, error) { 41 return client.SecretInspectWithRaw(ctx, id) 42 } 43 44 return inspect.Inspect(dockerCli.Out(), ids, opts.format, getRef) 45 }