github.com/fabiokung/docker@v0.11.2-0.20170222101415-4534dcd49497/cli/command/stack/opts.go (about) 1 package stack 2 3 import ( 4 "fmt" 5 "io" 6 "os" 7 8 "github.com/docker/docker/cli/command/bundlefile" 9 "github.com/spf13/pflag" 10 ) 11 12 func addComposefileFlag(opt *string, flags *pflag.FlagSet) { 13 flags.StringVarP(opt, "compose-file", "c", "", "Path to a Compose file") 14 flags.SetAnnotation("compose-file", "version", []string{"1.25"}) 15 } 16 17 func addBundlefileFlag(opt *string, flags *pflag.FlagSet) { 18 flags.StringVar(opt, "bundle-file", "", "Path to a Distributed Application Bundle file") 19 flags.SetAnnotation("bundle-file", "experimental", nil) 20 } 21 22 func addRegistryAuthFlag(opt *bool, flags *pflag.FlagSet) { 23 flags.BoolVar(opt, "with-registry-auth", false, "Send registry authentication details to Swarm agents") 24 } 25 26 func loadBundlefile(stderr io.Writer, namespace string, path string) (*bundlefile.Bundlefile, error) { 27 defaultPath := fmt.Sprintf("%s.dab", namespace) 28 29 if path == "" { 30 path = defaultPath 31 } 32 if _, err := os.Stat(path); err != nil { 33 return nil, fmt.Errorf( 34 "Bundle %s not found. Specify the path with --file", 35 path) 36 } 37 38 fmt.Fprintf(stderr, "Loading bundle from %s\n", path) 39 reader, err := os.Open(path) 40 if err != nil { 41 return nil, err 42 } 43 defer reader.Close() 44 45 bundle, err := bundlefile.LoadFile(reader) 46 if err != nil { 47 return nil, fmt.Errorf("Error reading %s: %v\n", path, err) 48 } 49 return bundle, err 50 }