github.com/vieux/docker@v0.6.3-0.20161004191708-e097c2a938c7/cli/command/stack/config.go (about) 1 // +build experimental 2 3 package stack 4 5 import ( 6 "github.com/docker/docker/cli" 7 "github.com/docker/docker/cli/command" 8 "github.com/docker/docker/cli/command/bundlefile" 9 "github.com/spf13/cobra" 10 ) 11 12 type configOptions struct { 13 bundlefile string 14 namespace string 15 } 16 17 func newConfigCommand(dockerCli *command.DockerCli) *cobra.Command { 18 var opts configOptions 19 20 cmd := &cobra.Command{ 21 Use: "config [OPTIONS] STACK", 22 Short: "Print the stack configuration", 23 Args: cli.ExactArgs(1), 24 RunE: func(cmd *cobra.Command, args []string) error { 25 opts.namespace = args[0] 26 return runConfig(dockerCli, opts) 27 }, 28 } 29 30 flags := cmd.Flags() 31 addBundlefileFlag(&opts.bundlefile, flags) 32 return cmd 33 } 34 35 func runConfig(dockerCli *command.DockerCli, opts configOptions) error { 36 bundle, err := loadBundlefile(dockerCli.Err(), opts.namespace, opts.bundlefile) 37 if err != nil { 38 return err 39 } 40 return bundlefile.Print(dockerCli.Out(), bundle) 41 }