1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/api/client/stack/opts.go
Daniel Nephin 71104bb592 Add experimental docker stack commands
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2016-06-14 14:56:35 -04:00

39 lines
840 B
Go

// +build experimental
package stack
import (
"fmt"
"io"
"os"
"github.com/docker/docker/api/client/bundlefile"
"github.com/spf13/pflag"
)
func addBundlefileFlag(opt *string, flags *pflag.FlagSet) {
flags.StringVarP(
opt,
"bundle", "f", "",
"Path to a bundle (Default: STACK.dsb)")
}
func loadBundlefile(stderr io.Writer, namespace string, path string) (*bundlefile.Bundlefile, error) {
defaultPath := fmt.Sprintf("%s.dsb", namespace)
if path == "" {
path = defaultPath
}
if _, err := os.Stat(path); err != nil {
return nil, fmt.Errorf(
"Bundle %s not found. Specify the path with -f or --bundle",
path)
}
fmt.Fprintf(stderr, "Loading bundle from %s\n", path)
bundle, err := bundlefile.LoadFile(path)
if err != nil {
return nil, fmt.Errorf("Error reading %s: %v\n", path, err)
}
return bundle, err
}