Skip to content

client: some cleanups#46133

Merged
cpuguy83 merged 3 commits intomoby:masterfrom
thaJeztah:client_cleanup
Aug 3, 2023
Merged

client: some cleanups#46133
cpuguy83 merged 3 commits intomoby:masterfrom
thaJeztah:client_cleanup

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

I had these lying around, but didn't push them yet.

I modified the last commit from what I originally had (originally I inlined the code), after noticing that #45652 also refactored the same code, but we decided to make a cli.tlsConfig() method, so I already introduced that method, for it to be updated with the OTEL changes in #45652

client/buildkit: ClientOpts: update docs to use doc-links, and inline

inline the closures, and update the GoDoc to use doc-links to the related
buildkit function.

client: Dialer: inline fallbackDial

fallbackDial was only used in a single place, and it was defined far away
from where it's used, so let's inline it, so that it's clear at a glance
what we're doing.

client: move resolveTLSConfig to a Client.tlsConfig()

This makes it slightly clearer what it does, as "resolve" may give the
impression it's doing more than just returning the TLS config configured
for the client.

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztah thaJeztah added status/2-code-review kind/refactor PR's that refactor, or clean-up code labels Aug 1, 2023
Comment thread client/client.go
Comment on lines +219 to +222
// tlsConfig returns the TLS configuration from the client's transport.
// It returns nil if the transport is not a [http.Transport], or if no
// TLSClientConfig is set.
func (cli *Client) tlsConfig() *tls.Config {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small note; I put this function after defaultHTTPClient() so that all methods on the Client are together, and to put it closer to where it's used 😅 (@cpuguy83's PR put it above defaultHTTPClient()

@thaJeztah thaJeztah requested a review from cpuguy83 August 1, 2023 10:21
@thaJeztah thaJeztah changed the title client: some clean-ups client: some cleanups Aug 1, 2023
@thaJeztah thaJeztah marked this pull request as draft August 1, 2023 13:59
inline the closures, and update the GoDoc to use doc-links to the related
buildkit function.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
fallbackDial was only used in a single place, and it was defined far away
from where it's used, so let's inline it, so that it's clear at a glance
what we're doing.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
This makes it slightly clearer what it does, as "resolve" may give the
impression it's doing more than just returning the TLS config configured
for the client.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah
Copy link
Copy Markdown
Member Author

@cpuguy83 ptal 🤗

@cpuguy83 cpuguy83 merged commit 25be5c9 into moby:master Aug 3, 2023
@thaJeztah thaJeztah deleted the client_cleanup branch August 3, 2023 17:26
@thaJeztah thaJeztah added this to the 25.0.0 milestone Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/refactor PR's that refactor, or clean-up code status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants