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