github.com/portworx/docker@v1.12.1/api/client/stack/config.go (about) 1 // +build experimental 2 3 package stack 4 5 import ( 6 "github.com/docker/docker/api/client" 7 "github.com/docker/docker/api/client/bundlefile" 8 "github.com/docker/docker/cli" 9 "github.com/spf13/cobra" 10 ) 11 12 type configOptions struct { 13 bundlefile string 14 namespace string 15 } 16 17 func newConfigCommand(dockerCli *client.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 *client.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 }