From eb2ac4301f26b6031c7aad48657a5ac30adca8a4 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Fri, 15 May 2015 17:37:32 -0700 Subject: [PATCH] Lint and documentation fixes Signed-off-by: Derek McGowan (github: dmcgowan) --- docs/client/blob_writer_test.go | 2 +- docs/client/transport/http_reader.go | 3 +++ docs/client/transport/transport.go | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/client/blob_writer_test.go b/docs/client/blob_writer_test.go index 0cc20da4..4d2ae862 100644 --- a/docs/client/blob_writer_test.go +++ b/docs/client/blob_writer_test.go @@ -152,7 +152,7 @@ func TestUploadReadFrom(t *testing.T) { t.Fatalf("Expected error when not found") } if err != distribution.ErrBlobUploadUnknown { - t.Fatalf("Wrong error thrown: %s, expected", err, distribution.ErrBlobUploadUnknown) + t.Fatalf("Wrong error thrown: %s, expected %s", err, distribution.ErrBlobUploadUnknown) } // 400 valid json diff --git a/docs/client/transport/http_reader.go b/docs/client/transport/http_reader.go index de728a96..d10d37e0 100644 --- a/docs/client/transport/http_reader.go +++ b/docs/client/transport/http_reader.go @@ -13,6 +13,9 @@ import ( "github.com/docker/distribution" ) +// NewHTTPReadSeeker handles reading from an HTTP endpoint using a GET +// request. When seeking and starting a read from a non-zero offset +// the a "Range" header will be added which sets the offset. func NewHTTPReadSeeker(client *http.Client, url string, size int64) distribution.ReadSeekCloser { return &httpReadSeeker{ client: client, diff --git a/docs/client/transport/transport.go b/docs/client/transport/transport.go index c8cfbb19..30e45fab 100644 --- a/docs/client/transport/transport.go +++ b/docs/client/transport/transport.go @@ -6,12 +6,16 @@ import ( "sync" ) +// RequestModifier represents an object which will do an inplace +// modification of an HTTP request. type RequestModifier interface { ModifyRequest(*http.Request) error } type headerModifier http.Header +// NewHeaderRequestModifier returns a new RequestModifier which will +// add the given headers to a request. func NewHeaderRequestModifier(header http.Header) RequestModifier { return headerModifier(header) } @@ -24,6 +28,8 @@ func (h headerModifier) ModifyRequest(req *http.Request) error { return nil } +// NewTransport creates a new transport which will apply modifiers to +// the request on a RoundTrip call. func NewTransport(base http.RoundTripper, modifiers ...RequestModifier) http.RoundTripper { return &transport{ Modifiers: modifiers,