pkg/plugins/transport: remove RequestFactory interface
The client's transport can only be set by newClientWithTransport, which is not exported, and always uses a transport.HTTPTransport. However, requestFactory is mocked in one of the tests, so keep the interface, but make it a local, non-exported one. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
d12ec5f796
commit
77c03221c9
3 changed files with 8 additions and 14 deletions
|
@ -87,10 +87,16 @@ func newClientWithTransport(tr *transport.HTTPTransport, timeout time.Duration)
|
|||
}
|
||||
}
|
||||
|
||||
// requestFactory defines an interface that transports can implement to
|
||||
// create new requests. It's used in testing.
|
||||
type requestFactory interface {
|
||||
NewRequest(path string, data io.Reader) (*http.Request, error)
|
||||
}
|
||||
|
||||
// Client represents a plugin client.
|
||||
type Client struct {
|
||||
http *http.Client // http client to use
|
||||
requestFactory transport.RequestFactory
|
||||
requestFactory requestFactory
|
||||
}
|
||||
|
||||
// RequestOpts is the set of options that can be passed into a request
|
||||
|
|
|
@ -11,8 +11,7 @@ import (
|
|||
|
||||
func TestHTTPTransport(t *testing.T) {
|
||||
var r io.Reader
|
||||
roundTripper := &http.Transport{}
|
||||
newTransport := NewHTTPTransport(roundTripper, "http", "0.0.0.0")
|
||||
newTransport := NewHTTPTransport(&http.Transport{}, "http", "0.0.0.0")
|
||||
request, err := newTransport.NewRequest("", r)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
|
@ -1,15 +1,4 @@
|
|||
package transport // import "github.com/docker/docker/pkg/plugins/transport"
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// VersionMimetype is the Content-Type the engine sends to plugins.
|
||||
const VersionMimetype = "application/vnd.docker.plugins.v1.2+json"
|
||||
|
||||
// RequestFactory defines an interface that
|
||||
// transports can implement to create new requests.
|
||||
type RequestFactory interface {
|
||||
NewRequest(path string, data io.Reader) (*http.Request, error)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue