New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend client API with custom HTTP requests #37071
Conversation
I don't really see the context of why this would be needed in the mentioned issue. Also would it be better to add a method to get the HTTP client rather than having the API client itself perform the request? It seems weird to have the API client just do any random request. |
It might be a bit hard to follow with much of the context being lost due to the many rebases.
I really don't have enough experience with the design of moby and docker/CLI to answer that. |
@mat007 yeah having a exported method to get the client's http client would work too 👼 |
Or something to read the credentials. Is this just the tlsconfig? We could provide a copy of the tlsconfig easily enough. |
@cpuguy83 I changed the PR to now expose a |
client/client.go
Outdated
@@ -356,6 +356,11 @@ func (cli *Client) DaemonHost() string { | |||
return cli.host | |||
} | |||
|
|||
// HTTPClient returns the HTTP client bound to the server | |||
func (cli *Client) HTTPClient() *http.Client { | |||
return cli.client |
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.
Should this make a copy of the client?
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.
OK, I changed that. Still returning a pointer though as http.Client
functions take a pointer as receptor and it's more convenient to directly get a pointer there.
Codecov Report
@@ Coverage Diff @@
## master #37071 +/- ##
=========================================
Coverage ? 35.09%
=========================================
Files ? 615
Lines ? 45820
Branches ? 0
=========================================
Hits ? 16080
Misses ? 27630
Partials ? 2110 |
Signed-off-by: Mathieu Champlon <mathieu.champlon@docker.com>
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.
LGTM
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.
LGTM
- What I did
I made the client underlying HTTP client accessible, useful for instance for docker/cli#1034
- How I did it
Added a
HTTPClient()
accessor to theClient
interface.- A picture of a cute animal (not mandatory but encouraged)