From dfd331b2c8942dfe3f4dc28561885471f9ab6c50 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 18 Jul 2023 12:23:47 +0200 Subject: [PATCH] pkg/plugins/transport: export httpTransport, and return concrete type Make NewHTTPTransport return a concrete type. Signed-off-by: Sebastiaan van Stijn --- pkg/plugins/client.go | 4 ++-- pkg/plugins/transport/http.go | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/plugins/client.go b/pkg/plugins/client.go index 10f6a001cf..45fb3844be 100644 --- a/pkg/plugins/client.go +++ b/pkg/plugins/client.go @@ -26,7 +26,7 @@ const ( dummyHost = "plugin.moby.localhost" ) -func newTransport(addr string, tlsConfig *tlsconfig.Options) (transport.Transport, error) { +func newTransport(addr string, tlsConfig *tlsconfig.Options) (*transport.HTTPTransport, error) { tr := &http.Transport{} if tlsConfig != nil { @@ -77,7 +77,7 @@ func NewClientWithTimeout(addr string, tlsConfig *tlsconfig.Options, timeout tim } // newClientWithTransport creates a new plugin client with a given transport. -func newClientWithTransport(tr transport.Transport, timeout time.Duration) *Client { +func newClientWithTransport(tr *transport.HTTPTransport, timeout time.Duration) *Client { return &Client{ http: &http.Client{ Transport: tr, diff --git a/pkg/plugins/transport/http.go b/pkg/plugins/transport/http.go index e1d08505ed..e4c1979b8b 100644 --- a/pkg/plugins/transport/http.go +++ b/pkg/plugins/transport/http.go @@ -6,18 +6,18 @@ import ( "strings" ) -// httpTransport holds an http.RoundTripper +// HTTPTransport holds an [http.RoundTripper] // and information about the scheme and address the transport // sends request to. -type httpTransport struct { +type HTTPTransport struct { http.RoundTripper scheme string addr string } -// NewHTTPTransport creates a new httpTransport. -func NewHTTPTransport(r http.RoundTripper, scheme, addr string) Transport { - return httpTransport{ +// NewHTTPTransport creates a new HTTPTransport. +func NewHTTPTransport(r http.RoundTripper, scheme, addr string) *HTTPTransport { + return &HTTPTransport{ RoundTripper: r, scheme: scheme, addr: addr, @@ -26,7 +26,7 @@ func NewHTTPTransport(r http.RoundTripper, scheme, addr string) Transport { // NewRequest creates a new http.Request and sets the URL // scheme and address with the transport's fields. -func (t httpTransport) NewRequest(path string, data io.Reader) (*http.Request, error) { +func (t HTTPTransport) NewRequest(path string, data io.Reader) (*http.Request, error) { if !strings.HasPrefix(path, "/") { path = "/" + path }