Add experimental docker stack commands

Signed-off-by: Daniel Nephin <dnephin@docker.com>
Upstream-commit: 71104bb592dc98467d3828394eabcbe50ca22ae4
Component: engine
This commit is contained in:
Daniel Nephin
2016-06-08 13:47:46 -04:00
parent 7636cd663b
commit a4f6628660
13 changed files with 594 additions and 4 deletions

View File

@ -0,0 +1,41 @@
// +build experimental
package stack
import (
"github.com/docker/docker/api/client"
"github.com/docker/docker/api/client/bundlefile"
"github.com/docker/docker/cli"
"github.com/spf13/cobra"
)
type configOptions struct {
bundlefile string
namespace string
}
func newConfigCommand(dockerCli *client.DockerCli) *cobra.Command {
var opts configOptions
cmd := &cobra.Command{
Use: "config [OPTIONS] STACK",
Short: "Print the stack configuration",
Args: cli.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
opts.namespace = args[0]
return runConfig(dockerCli, opts)
},
}
flags := cmd.Flags()
addBundlefileFlag(&opts.bundlefile, flags)
return cmd
}
func runConfig(dockerCli *client.DockerCli, opts configOptions) error {
bundle, err := loadBundlefile(dockerCli.Err(), opts.namespace, opts.bundlefile)
if err != nil {
return err
}
return bundlefile.Print(dockerCli.Out(), bundle)
}