Skip to content

Commit

Permalink
Fix always listing nodes during docker stack ps command on Kubernetes…
Browse files Browse the repository at this point in the history
…. A user without node listing rights could not use this command as it always fails.

Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
  • Loading branch information
silvin-lubecki committed May 30, 2018
1 parent daf021f commit 66059a9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cli/command/stack/kubernetes/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func printTasks(dockerCli command.Cli, options options.PS, namespace string, cli
names := map[string]string{}
nodes := map[string]string{}

n, err := client.Nodes().List(metav1.ListOptions{})
n, err := listNodes(client, options.NoResolve)
if err != nil {
return err
}
Expand Down Expand Up @@ -103,3 +103,10 @@ func resolveNode(name string, nodes *apiv1.NodeList, noResolve bool) (string, er
}
return name, nil
}

func listNodes(client corev1.NodesGetter, noResolve bool) (*apiv1.NodeList, error) {
if noResolve {
return client.Nodes().List(metav1.ListOptions{})
}
return nil, nil
}

0 comments on commit 66059a9

Please sign in to comment.