1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Remove secrets as part of stack remove.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2017-01-18 14:40:29 -05:00
parent b3427e43ed
commit f0a5531c46
4 changed files with 105 additions and 21 deletions

View file

@ -5,13 +5,14 @@ import (
"io/ioutil"
"os"
"sort"
"strings"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/integration-cli/checker"
"github.com/go-check/check"
)
func (s *DockerSwarmSuite) TestStackRemove(c *check.C) {
func (s *DockerSwarmSuite) TestStackRemoveUnknown(c *check.C) {
d := s.AddDaemon(c, true, true)
stackArgs := append([]string{"stack", "remove", "UNKNOWN_STACK"})
@ -21,7 +22,7 @@ func (s *DockerSwarmSuite) TestStackRemove(c *check.C) {
c.Assert(out, check.Equals, "Nothing found in stack: UNKNOWN_STACK\n")
}
func (s *DockerSwarmSuite) TestStackTasks(c *check.C) {
func (s *DockerSwarmSuite) TestStackPSUnknown(c *check.C) {
d := s.AddDaemon(c, true, true)
stackArgs := append([]string{"stack", "ps", "UNKNOWN_STACK"})
@ -31,7 +32,7 @@ func (s *DockerSwarmSuite) TestStackTasks(c *check.C) {
c.Assert(out, check.Equals, "Nothing found in stack: UNKNOWN_STACK\n")
}
func (s *DockerSwarmSuite) TestStackServices(c *check.C) {
func (s *DockerSwarmSuite) TestStackServicesUnknown(c *check.C) {
d := s.AddDaemon(c, true, true)
stackArgs := append([]string{"stack", "services", "UNKNOWN_STACK"})
@ -99,6 +100,29 @@ func (s *DockerSwarmSuite) TestStackDeployWithSecretsTwice(c *check.C) {
c.Assert(err, checker.IsNil, check.Commentf(out))
}
func (s *DockerSwarmSuite) TestStackRemove(c *check.C) {
d := s.AddDaemon(c, true, true)
stackName := "testdeploy"
stackArgs := []string{
"stack", "deploy",
"--compose-file", "fixtures/deploy/remove.yaml",
stackName,
}
out, err := d.Cmd(stackArgs...)
c.Assert(err, checker.IsNil, check.Commentf(out))
out, err = d.Cmd("stack", "ps", stackName)
c.Assert(err, checker.IsNil)
c.Assert(strings.Split(strings.TrimSpace(out), "\n"), checker.HasLen, 2)
out, err = d.Cmd("stack", "rm", stackName)
c.Assert(err, checker.IsNil, check.Commentf(out))
c.Assert(out, checker.Contains, "Removing service testdeploy_web")
c.Assert(out, checker.Contains, "Removing network testdeploy_default")
c.Assert(out, checker.Contains, "Removing secret testdeploy_special")
}
type sortSecrets []swarm.SecretReference
func (s sortSecrets) Len() int { return len(s) }