-
Notifications
You must be signed in to change notification settings - Fork 163
Conversation
@@ -32,7 +34,7 @@ func (cli *Client) ImageBuild(options types.ImageBuildOptions) (types.ImageBuild | |||
headers.Add("X-Registry-Config", base64.URLEncoding.EncodeToString(buf)) | |||
headers.Set("Content-Type", "application/tar") | |||
|
|||
serverResp, err := cli.postRaw("/build", query, options.Context, headers) | |||
serverResp, err := cli.postRaw(context.Background(), "/build", query, options.Context, headers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my education, why not pass current context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I think this function should be allowed to pass a context too.
bdf4146
to
cd17298
Compare
I think we should have several examples on how to use the contexts before merging this in. @mathpl, I really appreciate some help with that if you're up to contribute. |
I'd be happy to contribute. Where would you want these, doc.go or actual code under an example directory? |
@mathpl either sounds good to me. I think the advantage of having them in a |
cd17298
to
ada26f0
Compare
I added an example of canceling logs stream. I think this is ready to merge, we can add more examples later. |
3efa4d4
to
564e6f0
Compare
testHookContextDoneBeforeHeaders() | ||
cancel() | ||
// Clean up after the goroutine calling client.Do: | ||
go func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the motivation for spawning a new goroutine here? I would expect Do
not to return until the cancellation is acknowledged and the response body is closed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0896856
to
2633c31
Compare
LGTM |
ContainerStart(containerID string) error | ||
ContainerStop(containerID string, timeout int) error | ||
ContainerTop(containerID string, arguments []string) (types.ContainerProcessList, error) | ||
ContainerUnpause(containerID string) error | ||
ContainerUpdate(containerID string, updateConfig container.UpdateConfig) error | ||
ContainerWait(containerID string) (int, error) | ||
CopyFromContainer(containerID, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) | ||
CopyFromContainer(ctx context.Context, containerID, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) | ||
CopyToContainer(options types.CopyToContainerOptions) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this non-cancelable?
Signed-off-by: David Calavera <david.calavera@gmail.com>
Use an interface rather than a direct struct. Signed-off-by: David Calavera <david.calavera@gmail.com>
2633c31
to
c0f0ce5
Compare
@LK4D4 I've made those two operations cancelable too. Thanks for checking. |
Signed-off-by: David Calavera <david.calavera@gmail.com>
c0f0ce5
to
7c18876
Compare
LGTM |
Make streaming operations cancellable.
This change adds a new context argument to all streaming operations to make them cancellable.
Fixes #4.
Signed-off-by: David Calavera david.calavera@gmail.com