Merge pull request #27322 from yongtang/25855-deploy-dab-extension

Allow `docker deploy` command accept stack with/without extension
This commit is contained in:
Tõnis Tiigi 2016-10-14 18:26:49 -07:00 committed by GitHub
commit 4a6b37eb3e
2 changed files with 19 additions and 1 deletions

View File

@ -4,6 +4,7 @@ package stack
import (
"fmt"
"strings"
"github.com/spf13/cobra"
"golang.org/x/net/context"
@ -34,7 +35,7 @@ func newDeployCommand(dockerCli *command.DockerCli) *cobra.Command {
Short: "Create and update a stack from a Distributed Application Bundle (DAB)",
Args: cli.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
opts.namespace = args[0]
opts.namespace = strings.TrimSuffix(args[0], ".dab")
return runDeploy(dockerCli, opts)
},
}

View File

@ -90,3 +90,20 @@ func (s *DockerSwarmSuite) TestStackWithDAB(c *check.C) {
c.Assert(err, checker.IsNil)
c.Assert(out, check.Equals, "NAME SERVICES\n")
}
func (s *DockerSwarmSuite) TestStackWithDABExtension(c *check.C) {
// setup
testStackName := "test.dab"
testDABFileName := testStackName
defer os.RemoveAll(testDABFileName)
err := ioutil.WriteFile(testDABFileName, []byte(testDAB), 0444)
c.Assert(err, checker.IsNil)
d := s.AddDaemon(c, true, true)
// deploy
stackArgs := []string{"stack", "deploy", testStackName}
out, err := d.Cmd(stackArgs...)
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Contains, "Loading bundle from test.dab\n")
c.Assert(out, checker.Contains, "Creating service test_srv1\n")
c.Assert(out, checker.Contains, "Creating service test_srv2\n")
}