2016-10-19 16:22:02 +00:00
|
|
|
package secret
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/docker/docker/cli"
|
|
|
|
"github.com/docker/docker/cli/command"
|
|
|
|
"github.com/docker/docker/cli/command/inspect"
|
|
|
|
"github.com/spf13/cobra"
|
2016-11-10 00:59:01 +00:00
|
|
|
"golang.org/x/net/context"
|
2016-10-19 16:22:02 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type inspectOptions struct {
|
2016-11-22 16:18:28 +00:00
|
|
|
names []string
|
2016-10-19 16:22:02 +00:00
|
|
|
format string
|
|
|
|
}
|
|
|
|
|
|
|
|
func newSecretInspectCommand(dockerCli *command.DockerCli) *cobra.Command {
|
|
|
|
opts := inspectOptions{}
|
|
|
|
cmd := &cobra.Command{
|
2016-11-18 06:28:21 +00:00
|
|
|
Use: "inspect [OPTIONS] SECRET [SECRET...]",
|
|
|
|
Short: "Display detailed information on one or more secrets",
|
2016-11-22 16:18:28 +00:00
|
|
|
Args: cli.RequiresMinArgs(1),
|
2016-10-19 16:22:02 +00:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
2016-11-22 16:18:28 +00:00
|
|
|
opts.names = args
|
2016-10-19 16:22:02 +00:00
|
|
|
return runSecretInspect(dockerCli, opts)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2016-11-29 15:44:12 +00:00
|
|
|
cmd.Flags().StringVarP(&opts.format, "format", "f", "", "Format the output using the given Go template")
|
2016-10-19 16:22:02 +00:00
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
func runSecretInspect(dockerCli *command.DockerCli, opts inspectOptions) error {
|
|
|
|
client := dockerCli.Client()
|
|
|
|
ctx := context.Background()
|
|
|
|
|
2016-11-22 16:18:28 +00:00
|
|
|
getRef := func(id string) (interface{}, []byte, error) {
|
2016-11-02 03:32:21 +00:00
|
|
|
return client.SecretInspectWithRaw(ctx, id)
|
2016-10-19 16:22:02 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 19:06:07 +00:00
|
|
|
return inspect.Inspect(dockerCli.Out(), opts.names, opts.format, getRef)
|
2016-10-19 16:22:02 +00:00
|
|
|
}
|