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:
Silvin Lubecki 2018-05-30 15:19:45 +02:00
parent daf021fe60
commit 66059a925b
1 changed files with 8 additions and 1 deletions

View File

@ -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
}