Create client transport package
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)master
							parent
							
								
									94e375c5d1
								
							
						
					
					
						commit
						2874454224
					
				| 
						 | 
					@ -18,16 +18,17 @@ import (
 | 
				
			||||||
	"github.com/docker/distribution"
 | 
						"github.com/docker/distribution"
 | 
				
			||||||
	"github.com/docker/distribution/context"
 | 
						"github.com/docker/distribution/context"
 | 
				
			||||||
	"github.com/docker/distribution/registry/api/v2"
 | 
						"github.com/docker/distribution/registry/api/v2"
 | 
				
			||||||
 | 
						"github.com/docker/distribution/registry/client/transport"
 | 
				
			||||||
	"github.com/docker/distribution/registry/storage/cache"
 | 
						"github.com/docker/distribution/registry/storage/cache"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewRepository creates a new Repository for the given repository name and endpoint
 | 
					// NewRepository creates a new Repository for the given repository name and base URL
 | 
				
			||||||
func NewRepository(ctx context.Context, name, endpoint string, transport http.RoundTripper) (distribution.Repository, error) {
 | 
					func NewRepository(ctx context.Context, name, baseURL string, transport http.RoundTripper) (distribution.Repository, error) {
 | 
				
			||||||
	if err := v2.ValidateRespositoryName(name); err != nil {
 | 
						if err := v2.ValidateRespositoryName(name); err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ub, err := v2.NewURLBuilderFromString(endpoint)
 | 
						ub, err := v2.NewURLBuilderFromString(baseURL)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -292,7 +293,7 @@ func (ls *blobs) Open(ctx context.Context, dgst digest.Digest) (distribution.Rea
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return NewHTTPReadSeeker(ls.repository.client, blobURL, stat.Length), nil
 | 
						return transport.NewHTTPReadSeeker(ls.repository.client, blobURL, stat.Length), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (ls *blobs) ServeBlob(ctx context.Context, w http.ResponseWriter, r *http.Request, dgst digest.Digest) error {
 | 
					func (ls *blobs) ServeBlob(ctx context.Context, w http.ResponseWriter, r *http.Request, dgst digest.Digest) error {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
package client
 | 
					package transport
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
package client
 | 
					package transport
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
package client
 | 
					package transport
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"bufio"
 | 
						"bufio"
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
package client
 | 
					package transport
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"encoding/json"
 | 
						"encoding/json"
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
package client
 | 
					package transport
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"encoding/base64"
 | 
						"encoding/base64"
 | 
				
			||||||
| 
						 | 
					@ -11,6 +11,12 @@ import (
 | 
				
			||||||
	"github.com/docker/distribution/testutil"
 | 
						"github.com/docker/distribution/testutil"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func testServer(rrm testutil.RequestResponseMap) (string, func()) {
 | 
				
			||||||
 | 
						h := testutil.NewHandler(rrm)
 | 
				
			||||||
 | 
						s := httptest.NewServer(h)
 | 
				
			||||||
 | 
						return s.URL, s.Close
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type testAuthenticationWrapper struct {
 | 
					type testAuthenticationWrapper struct {
 | 
				
			||||||
	headers   http.Header
 | 
						headers   http.Header
 | 
				
			||||||
	authCheck func(string) bool
 | 
						authCheck func(string) bool
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
package client
 | 
					package transport
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
		Loading…
	
		Reference in New Issue