Merge branch 'master' into simpler-build-upload
Conflicts: api.go builder_client.go commands.gomaster
						commit
						580d393d3c
					
				| 
						 | 
					@ -7,10 +7,10 @@ import (
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"github.com/dotcloud/docker/auth"
 | 
						"github.com/dotcloud/docker/auth"
 | 
				
			||||||
	"github.com/dotcloud/docker/utils"
 | 
						"github.com/dotcloud/docker/utils"
 | 
				
			||||||
	"github.com/shin-/cookiejar"
 | 
					 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
	"io/ioutil"
 | 
						"io/ioutil"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
 | 
						"net/http/cookiejar"
 | 
				
			||||||
	"net/url"
 | 
						"net/url"
 | 
				
			||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
| 
						 | 
					@ -156,7 +156,7 @@ func (r *Registry) GetRemoteTags(registries []string, repository string, token [
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for _, host := range registries {
 | 
						for _, host := range registries {
 | 
				
			||||||
		endpoint := fmt.Sprintf("https://%s/v1/repositories/%s/tags", host, repository)
 | 
							endpoint := fmt.Sprintf("https://%s/v1/repositories/%s/tags", host, repository)
 | 
				
			||||||
		req, err := http.NewRequest("GET", endpoint, nil)
 | 
							req, err := r.opaqueRequest("GET", endpoint, nil)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return nil, err
 | 
								return nil, err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -190,7 +190,7 @@ func (r *Registry) GetRemoteTags(registries []string, repository string, token [
 | 
				
			||||||
func (r *Registry) GetRepositoryData(remote string) (*RepositoryData, error) {
 | 
					func (r *Registry) GetRepositoryData(remote string) (*RepositoryData, error) {
 | 
				
			||||||
	repositoryTarget := auth.IndexServerAddress() + "/repositories/" + remote + "/images"
 | 
						repositoryTarget := auth.IndexServerAddress() + "/repositories/" + remote + "/images"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	req, err := http.NewRequest("GET", repositoryTarget, nil)
 | 
						req, err := r.opaqueRequest("GET", repositoryTarget, nil)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -309,6 +309,15 @@ func (r *Registry) PushImageLayerRegistry(imgId string, layer io.Reader, registr
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (r *Registry) opaqueRequest(method, urlStr string, body io.Reader) (*http.Request, error) {
 | 
				
			||||||
 | 
						req, err := http.NewRequest(method, urlStr, body)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						req.URL.Opaque = strings.Replace(urlStr, req.URL.Scheme+":", "", 1)
 | 
				
			||||||
 | 
						return req, err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// push a tag on the registry.
 | 
					// push a tag on the registry.
 | 
				
			||||||
// Remote has the format '<user>/<repo>
 | 
					// Remote has the format '<user>/<repo>
 | 
				
			||||||
func (r *Registry) PushRegistryTag(remote, revision, tag, registry string, token []string) error {
 | 
					func (r *Registry) PushRegistryTag(remote, revision, tag, registry string, token []string) error {
 | 
				
			||||||
| 
						 | 
					@ -316,7 +325,7 @@ func (r *Registry) PushRegistryTag(remote, revision, tag, registry string, token
 | 
				
			||||||
	revision = "\"" + revision + "\""
 | 
						revision = "\"" + revision + "\""
 | 
				
			||||||
	registry = "https://" + registry + "/v1"
 | 
						registry = "https://" + registry + "/v1"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	req, err := http.NewRequest("PUT", registry+"/repositories/"+remote+"/tags/"+tag, strings.NewReader(revision))
 | 
						req, err := r.opaqueRequest("PUT", registry+"/repositories/"+remote+"/tags/"+tag, strings.NewReader(revision))
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -346,7 +355,7 @@ func (r *Registry) PushImageJSONIndex(remote string, imgList []*ImgData, validat
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	utils.Debugf("Image list pushed to index:\n%s\n", imgListJSON)
 | 
						utils.Debugf("Image list pushed to index:\n%s\n", imgListJSON)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	req, err := http.NewRequest("PUT", auth.IndexServerAddress()+"/repositories/"+remote+"/"+suffix, bytes.NewReader(imgListJSON))
 | 
						req, err := r.opaqueRequest("PUT", auth.IndexServerAddress()+"/repositories/"+remote+"/"+suffix, bytes.NewReader(imgListJSON))
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -366,7 +375,7 @@ func (r *Registry) PushImageJSONIndex(remote string, imgList []*ImgData, validat
 | 
				
			||||||
	// Redirect if necessary
 | 
						// Redirect if necessary
 | 
				
			||||||
	for res.StatusCode >= 300 && res.StatusCode < 400 {
 | 
						for res.StatusCode >= 300 && res.StatusCode < 400 {
 | 
				
			||||||
		utils.Debugf("Redirected to %s\n", res.Header.Get("Location"))
 | 
							utils.Debugf("Redirected to %s\n", res.Header.Get("Location"))
 | 
				
			||||||
		req, err = http.NewRequest("PUT", res.Header.Get("Location"), bytes.NewReader(imgListJSON))
 | 
							req, err = r.opaqueRequest("PUT", res.Header.Get("Location"), bytes.NewReader(imgListJSON))
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return nil, err
 | 
								return nil, err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -444,11 +453,6 @@ func (r *Registry) SearchRepositories(term string) (*SearchResults, error) {
 | 
				
			||||||
	return result, err
 | 
						return result, err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (r *Registry) ResetClient(authConfig *auth.AuthConfig) {
 | 
					 | 
				
			||||||
	r.authConfig = authConfig
 | 
					 | 
				
			||||||
	r.client.Jar = cookiejar.NewCookieJar()
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (r *Registry) GetAuthConfig(withPasswd bool) *auth.AuthConfig {
 | 
					func (r *Registry) GetAuthConfig(withPasswd bool) *auth.AuthConfig {
 | 
				
			||||||
	password := ""
 | 
						password := ""
 | 
				
			||||||
	if withPasswd {
 | 
						if withPasswd {
 | 
				
			||||||
| 
						 | 
					@ -484,18 +488,18 @@ type Registry struct {
 | 
				
			||||||
	authConfig *auth.AuthConfig
 | 
						authConfig *auth.AuthConfig
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func NewRegistry(root string, authConfig *auth.AuthConfig) *Registry {
 | 
					func NewRegistry(root string, authConfig *auth.AuthConfig) (r *Registry, err error) {
 | 
				
			||||||
	httpTransport := &http.Transport{
 | 
						httpTransport := &http.Transport{
 | 
				
			||||||
		DisableKeepAlives: true,
 | 
							DisableKeepAlives: true,
 | 
				
			||||||
		Proxy:             http.ProxyFromEnvironment,
 | 
							Proxy:             http.ProxyFromEnvironment,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	r := &Registry{
 | 
						r = &Registry{
 | 
				
			||||||
		authConfig: authConfig,
 | 
							authConfig: authConfig,
 | 
				
			||||||
		client: &http.Client{
 | 
							client: &http.Client{
 | 
				
			||||||
			Transport: httpTransport,
 | 
								Transport: httpTransport,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	r.client.Jar = cookiejar.NewCookieJar()
 | 
						r.client.Jar, err = cookiejar.New(nil)
 | 
				
			||||||
	return r
 | 
						return r, err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue