mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
71104bb592
Signed-off-by: Daniel Nephin <dnephin@docker.com>
39 lines
840 B
Go
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
|
|
}
|