Merge pull request #3916 from crosbymichael/bump_v0.8.0

Bump to v0.8.0
This commit is contained in:
Michael Crosby 2014-02-05 12:49:41 -05:00
commit b7246f179d

View file

@ -22,7 +22,7 @@ import (
var ( var (
ErrAlreadyExists = errors.New("Image already exists") ErrAlreadyExists = errors.New("Image already exists")
ErrInvalidRepositoryName = errors.New("Invalid repository name (ex: \"registry.domain.tld/myrepos\")") ErrInvalidRepositoryName = errors.New("Invalid repository name (ex: \"registry.domain.tld/myrepos\")")
ErrLoginRequired = errors.New("Authentication is required.") errLoginRequired = errors.New("Authentication is required.")
) )
func pingRegistryEndpoint(endpoint string) (bool, error) { func pingRegistryEndpoint(endpoint string) (bool, error) {
@ -186,7 +186,7 @@ func (r *Registry) GetRemoteHistory(imgID, registry string, token []string) ([]s
defer res.Body.Close() defer res.Body.Close()
if res.StatusCode != 200 { if res.StatusCode != 200 {
if res.StatusCode == 401 { if res.StatusCode == 401 {
return nil, ErrLoginRequired return nil, errLoginRequired
} }
return nil, utils.NewHTTPRequestError(fmt.Sprintf("Server error: %d trying to fetch remote history for %s", res.StatusCode, imgID), res) return nil, utils.NewHTTPRequestError(fmt.Sprintf("Server error: %d trying to fetch remote history for %s", res.StatusCode, imgID), res)
} }
@ -205,15 +205,18 @@ func (r *Registry) GetRemoteHistory(imgID, registry string, token []string) ([]s
} }
// Check if an image exists in the Registry // Check if an image exists in the Registry
// TODO: This method should return the errors instead of masking them and returning false
func (r *Registry) LookupRemoteImage(imgID, registry string, token []string) bool { func (r *Registry) LookupRemoteImage(imgID, registry string, token []string) bool {
req, err := r.reqFactory.NewRequest("GET", registry+"images/"+imgID+"/json", nil) req, err := r.reqFactory.NewRequest("GET", registry+"images/"+imgID+"/json", nil)
if err != nil { if err != nil {
utils.Errorf("Error in LookupRemoteImage %s", err)
return false return false
} }
setTokenAuth(req, token) setTokenAuth(req, token)
res, err := doWithCookies(r.client, req) res, err := doWithCookies(r.client, req)
if err != nil { if err != nil {
utils.Errorf("Error in LookupRemoteImage %s", err)
return false return false
} }
res.Body.Close() res.Body.Close()
@ -329,7 +332,7 @@ func (r *Registry) GetRepositoryData(remote string) (*RepositoryData, error) {
} }
defer res.Body.Close() defer res.Body.Close()
if res.StatusCode == 401 { if res.StatusCode == 401 {
return nil, ErrLoginRequired return nil, errLoginRequired
} }
// TODO: Right now we're ignoring checksums in the response body. // TODO: Right now we're ignoring checksums in the response body.
// In the future, we need to use them to check image validity. // In the future, we need to use them to check image validity.
@ -614,6 +617,10 @@ func (r *Registry) SearchRepositories(term string) (*SearchResults, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if r.authConfig != nil && len(r.authConfig.Username) > 0 {
req.SetBasicAuth(r.authConfig.Username, r.authConfig.Password)
}
req.Header.Set("X-Docker-Token", "true")
res, err := r.client.Do(req) res, err := r.client.Do(req)
if err != nil { if err != nil {
return nil, err return nil, err