client/node: Wrap options and output

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski
2025-10-22 12:01:37 +02:00
parent 25c509b026
commit 7ceea4148a
22 changed files with 145 additions and 76 deletions

View File

@@ -159,13 +159,13 @@ func JobComplete(ctx context.Context, apiClient client.ServiceAPIClient, service
func HasLeader(ctx context.Context, apiClient client.NodeAPIClient) func(log poll.LogT) poll.Result {
return func(log poll.LogT) poll.Result {
nodes, err := apiClient.NodeList(ctx, client.NodeListOptions{
result, err := apiClient.NodeList(ctx, client.NodeListOptions{
Filters: make(client.Filters).Add("role", "manager"),
})
if err != nil {
return poll.Error(err)
}
for _, node := range nodes {
for _, node := range result.Items {
if node.ManagerStatus != nil && node.ManagerStatus.Leader {
return poll.Success()
}

View File

@@ -165,11 +165,11 @@ func TestInspectNetwork(t *testing.T) {
t.Run("BeforeLeaderChange", checkNetworkInspect)
leaderID := func() string {
ls, err := c1.NodeList(ctx, client.NodeListOptions{
result, err := c1.NodeList(ctx, client.NodeListOptions{
Filters: make(client.Filters).Add("role", "manager"),
})
assert.NilError(t, err)
for _, node := range ls {
for _, node := range result.Items {
if node.ManagerStatus != nil && node.ManagerStatus.Leader {
return node.ID
}