mirror of https://github.com/docker/cli.git
Fix always listing nodes during docker stack ps command on Kubernetes. A user without node listing rights could not use this command as it always fails.
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
This commit is contained in:
parent
daf021fe60
commit
66059a925b
|
@ -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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue