mirror of https://github.com/docker/cli.git
Merge pull request #1093 from silvin-lubecki/fix-listing-nodes
Fix always listing nodes in docker stack ps command
This commit is contained in:
commit
a8ee42ad53
|
@ -68,7 +68,7 @@ func printTasks(dockerCli command.Cli, options options.PS, namespace string, cli
|
||||||
names := map[string]string{}
|
names := map[string]string{}
|
||||||
nodes := map[string]string{}
|
nodes := map[string]string{}
|
||||||
|
|
||||||
n, err := client.Nodes().List(metav1.ListOptions{})
|
n, err := listNodes(client, options.NoResolve)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -103,3 +103,10 @@ func resolveNode(name string, nodes *apiv1.NodeList, noResolve bool) (string, er
|
||||||
}
|
}
|
||||||
return name, nil
|
return name, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func listNodes(client corev1.NodesGetter, noResolve bool) (*apiv1.NodeList, error) {
|
||||||
|
if noResolve {
|
||||||
|
return client.Nodes().List(metav1.ListOptions{})
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/docker/cli/cli/command/stack/options"
|
"github.com/docker/cli/cli/command/stack/options"
|
||||||
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RunRemove is the kubernetes implementation of docker stack remove
|
// RunRemove is the kubernetes implementation of docker stack remove
|
||||||
|
@ -18,10 +19,8 @@ func RunRemove(dockerCli *KubeCli, opts options.Remove) error {
|
||||||
}
|
}
|
||||||
for _, stack := range opts.Namespaces {
|
for _, stack := range opts.Namespaces {
|
||||||
fmt.Fprintf(dockerCli.Out(), "Removing stack: %s\n", stack)
|
fmt.Fprintf(dockerCli.Out(), "Removing stack: %s\n", stack)
|
||||||
err := stacks.Delete(stack)
|
if err := stacks.Delete(stack); err != nil {
|
||||||
if err != nil {
|
return errors.Wrapf(err, "Failed to remove stack %s", stack)
|
||||||
fmt.Fprintf(dockerCli.Out(), "Failed to remove stack %s: %s\n", stack, err)
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue