github.com/kobeld/docker@v1.12.0-rc1/api/client/swarm/inspect.go (about) 1 package swarm 2 3 import ( 4 "golang.org/x/net/context" 5 6 "github.com/docker/docker/api/client" 7 "github.com/docker/docker/api/client/inspect" 8 "github.com/docker/docker/cli" 9 "github.com/spf13/cobra" 10 ) 11 12 type inspectOptions struct { 13 format string 14 // pretty bool 15 } 16 17 func newInspectCommand(dockerCli *client.DockerCli) *cobra.Command { 18 var opts inspectOptions 19 20 cmd := &cobra.Command{ 21 Use: "inspect [OPTIONS]", 22 Short: "Inspect the Swarm", 23 Args: cli.NoArgs, 24 RunE: func(cmd *cobra.Command, args []string) error { 25 // if opts.pretty && len(opts.format) > 0 { 26 // return fmt.Errorf("--format is incompatible with human friendly format") 27 // } 28 return runInspect(dockerCli, opts) 29 }, 30 } 31 32 flags := cmd.Flags() 33 flags.StringVarP(&opts.format, "format", "f", "", "Format the output using the given go template") 34 //flags.BoolVarP(&opts.pretty, "pretty", "h", false, "Print the information in a human friendly format.") 35 return cmd 36 } 37 38 func runInspect(dockerCli *client.DockerCli, opts inspectOptions) error { 39 client := dockerCli.Client() 40 ctx := context.Background() 41 42 swarm, err := client.SwarmInspect(ctx) 43 if err != nil { 44 return err 45 } 46 47 getRef := func(_ string) (interface{}, []byte, error) { 48 return swarm, nil, nil 49 } 50 51 // if !opts.pretty { 52 return inspect.Inspect(dockerCli.Out(), []string{""}, opts.format, getRef) 53 // } 54 55 //return printHumanFriendly(dockerCli.Out(), opts.refs, getRef) 56 }