mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client: ExecCreateResult: define local type with ID field
The `ExecCreateResult` was embedding the `container.ExecCreateRespons`,
which in itself was an alias for `common.IDResponse`. This type has a
single field (`ID`) currently, but the embedding made it awkward to use,
for example, when mocking a `ExecCreateResult` using struct-literals:
func execCreateWithID(_ string, _ client.ExecCreateOptions) (client.ExecCreateResult, error) {
return client.ExecCreateResult{ExecCreateResponse: container.ExecCreateResponse{ID: "execid"}}, nil
}
This patch defines it as a local type with the `ID` as field.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -58,11 +58,11 @@ func Exec(ctx context.Context, apiClient client.APIClient, id string, cmd []stri
|
||||
op(&execOptions)
|
||||
}
|
||||
|
||||
cresp, err := apiClient.ExecCreate(ctx, id, execOptions)
|
||||
res, err := apiClient.ExecCreate(ctx, id, execOptions)
|
||||
if err != nil {
|
||||
return ExecResult{}, err
|
||||
}
|
||||
execID := cresp.ID
|
||||
execID := res.ID
|
||||
|
||||
// run it, with stdout/stderr attached
|
||||
aresp, err := apiClient.ExecAttach(ctx, execID, client.ExecAttachOptions{})
|
||||
|
||||
@@ -237,10 +237,10 @@ func ExecTask(ctx context.Context, t *testing.T, d *daemon.Daemon, task swarmtyp
|
||||
apiClient := d.NewClientT(t)
|
||||
defer apiClient.Close()
|
||||
|
||||
resp, err := apiClient.ExecCreate(ctx, task.Status.ContainerStatus.ContainerID, options)
|
||||
res, err := apiClient.ExecCreate(ctx, task.Status.ContainerStatus.ContainerID, options)
|
||||
assert.NilError(t, err, "error creating exec")
|
||||
|
||||
attach, err := apiClient.ExecAttach(ctx, resp.ID, client.ExecAttachOptions{})
|
||||
attach, err := apiClient.ExecAttach(ctx, res.ID, client.ExecAttachOptions{})
|
||||
assert.NilError(t, err, "error attaching to exec")
|
||||
return attach.HijackedResponse
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user