mirror of https://github.com/docker/docs.git
return err when stack name does not exist
Signed-off-by: allencloud <allen.sun@daocloud.io> (cherry picked from commit 416613f2e54581c62d3efa1c4f0288b6e7d58365) Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
parent
e07a1af84b
commit
25b235a1b1
|
@ -35,7 +35,7 @@ func NewNodeCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reference return the reference of a node. The special value "self" for a node
|
// Reference returns the reference of a node. The special value "self" for a node
|
||||||
// reference is mapped to the current node, hence the node ID is retrieved using
|
// reference is mapped to the current node, hence the node ID is retrieved using
|
||||||
// the `/info` endpoint.
|
// the `/info` endpoint.
|
||||||
func Reference(client apiclient.APIClient, ctx context.Context, ref string) (string, error) {
|
func Reference(client apiclient.APIClient, ctx context.Context, ref string) (string, error) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ func NewStackCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTopLevelDeployCommand return a command for `docker deploy`
|
// NewTopLevelDeployCommand returns a command for `docker deploy`
|
||||||
func NewTopLevelDeployCommand(dockerCli *client.DockerCli) *cobra.Command {
|
func NewTopLevelDeployCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||||
cmd := newDeployCommand(dockerCli)
|
cmd := newDeployCommand(dockerCli)
|
||||||
// Remove the aliases at the top level
|
// Remove the aliases at the top level
|
||||||
|
|
|
@ -63,6 +63,11 @@ func runRemove(dockerCli *client.DockerCli, opts removeOptions) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(services) == 0 && len(networks) == 0 {
|
||||||
|
fmt.Fprintf(dockerCli.Out(), "Nothing found in stack: %s\n", namespace)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if hasError {
|
if hasError {
|
||||||
return fmt.Errorf("Failed to remove some resources")
|
return fmt.Errorf("Failed to remove some resources")
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
package stack
|
package stack
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
|
|
||||||
"github.com/docker/docker/api/client"
|
"github.com/docker/docker/api/client"
|
||||||
|
@ -43,6 +45,7 @@ func newTasksCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
func runTasks(dockerCli *client.DockerCli, opts tasksOptions) error {
|
func runTasks(dockerCli *client.DockerCli, opts tasksOptions) error {
|
||||||
|
namespace := opts.namespace
|
||||||
client := dockerCli.Client()
|
client := dockerCli.Client()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
|
@ -58,5 +61,10 @@ func runTasks(dockerCli *client.DockerCli, opts tasksOptions) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(tasks) == 0 {
|
||||||
|
fmt.Fprintf(dockerCli.Out(), "Nothing found in stack: %s\n", namespace)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
return task.Print(dockerCli, ctx, tasks, idresolver.New(client, opts.noResolve))
|
return task.Print(dockerCli, ctx, tasks, idresolver.New(client, opts.noResolve))
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
// +build experimental
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/docker/docker/pkg/integration/checker"
|
||||||
|
"github.com/go-check/check"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s *DockerSwarmSuite) TestStackRemove(c *check.C) {
|
||||||
|
d := s.AddDaemon(c, true, true)
|
||||||
|
|
||||||
|
stackArgs := append([]string{"remove", "UNKNOWN_STACK"})
|
||||||
|
|
||||||
|
out, err := d.Cmd("stack", stackArgs...)
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
c.Assert(out, check.Equals, "Nothing found in stack: UNKNOWN_STACK\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *DockerSwarmSuite) TestStackTasks(c *check.C) {
|
||||||
|
d := s.AddDaemon(c, true, true)
|
||||||
|
|
||||||
|
stackArgs := append([]string{"tasks", "UNKNOWN_STACK"})
|
||||||
|
|
||||||
|
out, err := d.Cmd("stack", stackArgs...)
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
c.Assert(out, check.Equals, "Nothing found in stack: UNKNOWN_STACK\n")
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
// Package checker provide Docker specific implementations of the go-check.Checker interface.
|
// Package checker provides Docker specific implementations of the go-check.Checker interface.
|
||||||
package checker
|
package checker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
Loading…
Reference in New Issue