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

@@ -20,7 +20,7 @@ func (d *Daemon) GetNode(ctx context.Context, t testing.TB, id string, errCheck
cli := d.NewClientT(t)
defer cli.Close()
node, _, err := cli.NodeInspectWithRaw(ctx, id)
result, err := cli.NodeInspect(ctx, id, client.NodeInspectOptions{})
if err != nil {
for _, f := range errCheck {
if f(err) {
@@ -28,9 +28,9 @@ func (d *Daemon) GetNode(ctx context.Context, t testing.TB, id string, errCheck
}
}
}
assert.NilError(t, err, "[%s] (*Daemon).GetNode: NodeInspectWithRaw(%q) failed", d.id, id)
assert.Check(t, node.ID == id)
return &node
assert.NilError(t, err, "[%s] (*Daemon).GetNode: NodeInspect(%q) failed", d.id, id)
assert.Check(t, result.Node.ID == id)
return &result.Node
}
// RemoveNode removes the specified node
@@ -42,7 +42,7 @@ func (d *Daemon) RemoveNode(ctx context.Context, t testing.TB, id string, force
options := client.NodeRemoveOptions{
Force: force,
}
err := cli.NodeRemove(ctx, id, options)
_, err := cli.NodeRemove(ctx, id, options)
assert.NilError(t, err)
}
@@ -58,7 +58,10 @@ func (d *Daemon) UpdateNode(ctx context.Context, t testing.TB, id string, f ...N
fn(node)
}
err := cli.NodeUpdate(ctx, node.ID, node.Version, node.Spec)
_, err := cli.NodeUpdate(ctx, node.ID, client.NodeUpdateOptions{
Version: node.Version,
Node: node.Spec,
})
if i < 10 && err != nil && strings.Contains(err.Error(), "update out of sequence") {
time.Sleep(100 * time.Millisecond)
continue
@@ -74,8 +77,8 @@ func (d *Daemon) ListNodes(ctx context.Context, t testing.TB) []swarm.Node {
cli := d.NewClientT(t)
defer cli.Close()
nodes, err := cli.NodeList(ctx, client.NodeListOptions{})
result, err := cli.NodeList(ctx, client.NodeListOptions{})
assert.NilError(t, err)
return nodes
return result.Items
}