Replace aliased imports of logrus, fixes #11762

Signed-off-by: Antonio Murdaca <me@runcom.ninja>
This commit is contained in:
Antonio Murdaca 2015-03-26 23:22:04 +01:00
parent eff5278d12
commit d5045d054b
7 changed files with 62 additions and 62 deletions

View file

@ -13,7 +13,7 @@ import (
"sync" "sync"
"time" "time"
log "github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/docker/utils" "github.com/docker/docker/utils"
) )
@ -66,7 +66,7 @@ func (auth *RequestAuthorization) getToken() (string, error) {
defer auth.tokenLock.Unlock() defer auth.tokenLock.Unlock()
now := time.Now() now := time.Now()
if now.Before(auth.tokenExpiration) { if now.Before(auth.tokenExpiration) {
log.Debugf("Using cached token for %s", auth.authConfig.Username) logrus.Debugf("Using cached token for %s", auth.authConfig.Username)
return auth.tokenCache, nil return auth.tokenCache, nil
} }
@ -78,7 +78,7 @@ func (auth *RequestAuthorization) getToken() (string, error) {
case "basic": case "basic":
// no token necessary // no token necessary
case "bearer": case "bearer":
log.Debugf("Getting bearer token with %s for %s", challenge.Parameters, auth.authConfig.Username) logrus.Debugf("Getting bearer token with %s for %s", challenge.Parameters, auth.authConfig.Username)
params := map[string]string{} params := map[string]string{}
for k, v := range challenge.Parameters { for k, v := range challenge.Parameters {
params[k] = v params[k] = v
@ -93,7 +93,7 @@ func (auth *RequestAuthorization) getToken() (string, error) {
return token, nil return token, nil
default: default:
log.Infof("Unsupported auth scheme: %q", challenge.Scheme) logrus.Infof("Unsupported auth scheme: %q", challenge.Scheme)
} }
} }
@ -245,7 +245,7 @@ func loginV1(authConfig *AuthConfig, registryEndpoint *Endpoint, factory *utils.
serverAddress = authConfig.ServerAddress serverAddress = authConfig.ServerAddress
) )
log.Debugf("attempting v1 login to registry endpoint %s", registryEndpoint) logrus.Debugf("attempting v1 login to registry endpoint %s", registryEndpoint)
if serverAddress == "" { if serverAddress == "" {
return "", fmt.Errorf("Server Error: Server Address not set.") return "", fmt.Errorf("Server Error: Server Address not set.")
@ -349,7 +349,7 @@ func loginV1(authConfig *AuthConfig, registryEndpoint *Endpoint, factory *utils.
// served by the v2 registry service provider. Whether this will be supported in the future // served by the v2 registry service provider. Whether this will be supported in the future
// is to be determined. // is to be determined.
func loginV2(authConfig *AuthConfig, registryEndpoint *Endpoint, factory *utils.HTTPRequestFactory) (string, error) { func loginV2(authConfig *AuthConfig, registryEndpoint *Endpoint, factory *utils.HTTPRequestFactory) (string, error) {
log.Debugf("attempting v2 login to registry endpoint %s", registryEndpoint) logrus.Debugf("attempting v2 login to registry endpoint %s", registryEndpoint)
var ( var (
err error err error
allErrors []error allErrors []error
@ -357,7 +357,7 @@ func loginV2(authConfig *AuthConfig, registryEndpoint *Endpoint, factory *utils.
) )
for _, challenge := range registryEndpoint.AuthChallenges { for _, challenge := range registryEndpoint.AuthChallenges {
log.Debugf("trying %q auth challenge with params %s", challenge.Scheme, challenge.Parameters) logrus.Debugf("trying %q auth challenge with params %s", challenge.Scheme, challenge.Parameters)
switch strings.ToLower(challenge.Scheme) { switch strings.ToLower(challenge.Scheme) {
case "basic": case "basic":
@ -373,7 +373,7 @@ func loginV2(authConfig *AuthConfig, registryEndpoint *Endpoint, factory *utils.
return "Login Succeeded", nil return "Login Succeeded", nil
} }
log.Debugf("error trying auth challenge %q: %s", challenge.Scheme, err) logrus.Debugf("error trying auth challenge %q: %s", challenge.Scheme, err)
allErrors = append(allErrors, err) allErrors = append(allErrors, err)
} }

View file

@ -10,7 +10,7 @@ import (
"net/url" "net/url"
"strings" "strings"
log "github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/docker/registry/v2" "github.com/docker/docker/registry/v2"
"github.com/docker/docker/utils" "github.com/docker/docker/utils"
) )
@ -57,7 +57,7 @@ func NewEndpoint(index *IndexInfo) (*Endpoint, error) {
} }
func validateEndpoint(endpoint *Endpoint) error { func validateEndpoint(endpoint *Endpoint) error {
log.Debugf("pinging registry endpoint %s", endpoint) logrus.Debugf("pinging registry endpoint %s", endpoint)
// Try HTTPS ping to registry // Try HTTPS ping to registry
endpoint.URL.Scheme = "https" endpoint.URL.Scheme = "https"
@ -69,7 +69,7 @@ func validateEndpoint(endpoint *Endpoint) error {
} }
// If registry is insecure and HTTPS failed, fallback to HTTP. // If registry is insecure and HTTPS failed, fallback to HTTP.
log.Debugf("Error from registry %q marked as insecure: %v. Insecurely falling back to HTTP", endpoint, err) logrus.Debugf("Error from registry %q marked as insecure: %v. Insecurely falling back to HTTP", endpoint, err)
endpoint.URL.Scheme = "http" endpoint.URL.Scheme = "http"
var err2 error var err2 error
@ -163,7 +163,7 @@ func (e *Endpoint) Ping() (RegistryInfo, error) {
} }
func (e *Endpoint) pingV1(factory *utils.HTTPRequestFactory) (RegistryInfo, error) { func (e *Endpoint) pingV1(factory *utils.HTTPRequestFactory) (RegistryInfo, error) {
log.Debugf("attempting v1 ping for registry endpoint %s", e) logrus.Debugf("attempting v1 ping for registry endpoint %s", e)
if e.String() == IndexServerAddress() { if e.String() == IndexServerAddress() {
// Skip the check, we know this one is valid // Skip the check, we know this one is valid
@ -194,17 +194,17 @@ func (e *Endpoint) pingV1(factory *utils.HTTPRequestFactory) (RegistryInfo, erro
Standalone: true, Standalone: true,
} }
if err := json.Unmarshal(jsonString, &info); err != nil { if err := json.Unmarshal(jsonString, &info); err != nil {
log.Debugf("Error unmarshalling the _ping RegistryInfo: %s", err) logrus.Debugf("Error unmarshalling the _ping RegistryInfo: %s", err)
// don't stop here. Just assume sane defaults // don't stop here. Just assume sane defaults
} }
if hdr := resp.Header.Get("X-Docker-Registry-Version"); hdr != "" { if hdr := resp.Header.Get("X-Docker-Registry-Version"); hdr != "" {
log.Debugf("Registry version header: '%s'", hdr) logrus.Debugf("Registry version header: '%s'", hdr)
info.Version = hdr info.Version = hdr
} }
log.Debugf("RegistryInfo.Version: %q", info.Version) logrus.Debugf("RegistryInfo.Version: %q", info.Version)
standalone := resp.Header.Get("X-Docker-Registry-Standalone") standalone := resp.Header.Get("X-Docker-Registry-Standalone")
log.Debugf("Registry standalone header: '%s'", standalone) logrus.Debugf("Registry standalone header: '%s'", standalone)
// Accepted values are "true" (case-insensitive) and "1". // Accepted values are "true" (case-insensitive) and "1".
if strings.EqualFold(standalone, "true") || standalone == "1" { if strings.EqualFold(standalone, "true") || standalone == "1" {
info.Standalone = true info.Standalone = true
@ -212,12 +212,12 @@ func (e *Endpoint) pingV1(factory *utils.HTTPRequestFactory) (RegistryInfo, erro
// there is a header set, and it is not "true" or "1", so assume fails // there is a header set, and it is not "true" or "1", so assume fails
info.Standalone = false info.Standalone = false
} }
log.Debugf("RegistryInfo.Standalone: %t", info.Standalone) logrus.Debugf("RegistryInfo.Standalone: %t", info.Standalone)
return info, nil return info, nil
} }
func (e *Endpoint) pingV2(factory *utils.HTTPRequestFactory) (RegistryInfo, error) { func (e *Endpoint) pingV2(factory *utils.HTTPRequestFactory) (RegistryInfo, error) {
log.Debugf("attempting v2 ping for registry endpoint %s", e) logrus.Debugf("attempting v2 ping for registry endpoint %s", e)
req, err := factory.NewRequest("GET", e.Path(""), nil) req, err := factory.NewRequest("GET", e.Path(""), nil)
if err != nil { if err != nil {

View file

@ -13,7 +13,7 @@ import (
"strings" "strings"
"time" "time"
log "github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/docker/pkg/timeoutconn" "github.com/docker/docker/pkg/timeoutconn"
) )
@ -100,7 +100,7 @@ func doRequest(req *http.Request, jar http.CookieJar, timeout TimeoutType, secur
} }
hostDir := path.Join("/etc/docker/certs.d", req.URL.Host) hostDir := path.Join("/etc/docker/certs.d", req.URL.Host)
log.Debugf("hostDir: %s", hostDir) logrus.Debugf("hostDir: %s", hostDir)
fs, err := ioutil.ReadDir(hostDir) fs, err := ioutil.ReadDir(hostDir)
if err != nil && !os.IsNotExist(err) { if err != nil && !os.IsNotExist(err) {
return nil, nil, err return nil, nil, err
@ -111,7 +111,7 @@ func doRequest(req *http.Request, jar http.CookieJar, timeout TimeoutType, secur
if pool == nil { if pool == nil {
pool = x509.NewCertPool() pool = x509.NewCertPool()
} }
log.Debugf("crt: %s", hostDir+"/"+f.Name()) logrus.Debugf("crt: %s", hostDir+"/"+f.Name())
data, err := ioutil.ReadFile(path.Join(hostDir, f.Name())) data, err := ioutil.ReadFile(path.Join(hostDir, f.Name()))
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
@ -121,7 +121,7 @@ func doRequest(req *http.Request, jar http.CookieJar, timeout TimeoutType, secur
if strings.HasSuffix(f.Name(), ".cert") { if strings.HasSuffix(f.Name(), ".cert") {
certName := f.Name() certName := f.Name()
keyName := certName[:len(certName)-5] + ".key" keyName := certName[:len(certName)-5] + ".key"
log.Debugf("cert: %s", hostDir+"/"+f.Name()) logrus.Debugf("cert: %s", hostDir+"/"+f.Name())
if !hasFile(fs, keyName) { if !hasFile(fs, keyName) {
return nil, nil, fmt.Errorf("Missing key %s for certificate %s", keyName, certName) return nil, nil, fmt.Errorf("Missing key %s for certificate %s", keyName, certName)
} }
@ -134,7 +134,7 @@ func doRequest(req *http.Request, jar http.CookieJar, timeout TimeoutType, secur
if strings.HasSuffix(f.Name(), ".key") { if strings.HasSuffix(f.Name(), ".key") {
keyName := f.Name() keyName := f.Name()
certName := keyName[:len(keyName)-4] + ".cert" certName := keyName[:len(keyName)-4] + ".cert"
log.Debugf("key: %s", hostDir+"/"+f.Name()) logrus.Debugf("key: %s", hostDir+"/"+f.Name())
if !hasFile(fs, certName) { if !hasFile(fs, certName) {
return nil, nil, fmt.Errorf("Missing certificate %s for key %s", certName, keyName) return nil, nil, fmt.Errorf("Missing certificate %s for key %s", certName, keyName)
} }

View file

@ -18,7 +18,7 @@ import (
"github.com/docker/docker/opts" "github.com/docker/docker/opts"
"github.com/gorilla/mux" "github.com/gorilla/mux"
log "github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
) )
var ( var (
@ -134,7 +134,7 @@ func init() {
func handlerAccessLog(handler http.Handler) http.Handler { func handlerAccessLog(handler http.Handler) http.Handler {
logHandler := func(w http.ResponseWriter, r *http.Request) { logHandler := func(w http.ResponseWriter, r *http.Request) {
log.Debugf("%s \"%s %s\"", r.RemoteAddr, r.Method, r.URL) logrus.Debugf("%s \"%s %s\"", r.RemoteAddr, r.Method, r.URL)
handler.ServeHTTP(w, r) handler.ServeHTTP(w, r)
} }
return http.HandlerFunc(logHandler) return http.HandlerFunc(logHandler)
@ -467,7 +467,7 @@ func TestPing(t *testing.T) {
* WARNING: Don't push on the repos uncommented, it'll block the tests * WARNING: Don't push on the repos uncommented, it'll block the tests
* *
func TestWait(t *testing.T) { func TestWait(t *testing.T) {
log.Println("Test HTTP server ready and waiting:", testHttpServer.URL) logrus.Println("Test HTTP server ready and waiting:", testHttpServer.URL)
c := make(chan int) c := make(chan int)
<-c <-c
} }

View file

@ -3,7 +3,7 @@ package registry
import ( import (
"fmt" "fmt"
log "github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/docker/engine" "github.com/docker/docker/engine"
) )
@ -62,18 +62,18 @@ func (s *Service) Auth(job *engine.Job) error {
} }
if endpoint, err = NewEndpoint(index); err != nil { if endpoint, err = NewEndpoint(index); err != nil {
log.Errorf("unable to get new registry endpoint: %s", err) logrus.Errorf("unable to get new registry endpoint: %s", err)
return err return err
} }
authConfig.ServerAddress = endpoint.String() authConfig.ServerAddress = endpoint.String()
if status, err = Login(authConfig, endpoint, HTTPRequestFactory(nil)); err != nil { if status, err = Login(authConfig, endpoint, HTTPRequestFactory(nil)); err != nil {
log.Errorf("unable to login against registry endpoint %s: %s", endpoint, err) logrus.Errorf("unable to login against registry endpoint %s: %s", endpoint, err)
return err return err
} }
log.Infof("successful registry login for endpoint %s: %s", endpoint, status) logrus.Infof("successful registry login for endpoint %s: %s", endpoint, status)
job.Printf("%s\n", status) job.Printf("%s\n", status)
return nil return nil

View file

@ -17,7 +17,7 @@ import (
"strings" "strings"
"time" "time"
log "github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/docker/pkg/httputils" "github.com/docker/docker/pkg/httputils"
"github.com/docker/docker/pkg/tarsum" "github.com/docker/docker/pkg/tarsum"
"github.com/docker/docker/utils" "github.com/docker/docker/utils"
@ -54,7 +54,7 @@ func NewSession(authConfig *AuthConfig, factory *utils.HTTPRequestFactory, endpo
return nil, err return nil, err
} }
if info.Standalone { if info.Standalone {
log.Debugf("Endpoint %s is eligible for private registry. Enabling decorator.", r.indexEndpoint.String()) logrus.Debugf("Endpoint %s is eligible for private registry. Enabling decorator.", r.indexEndpoint.String())
dec := utils.NewHTTPAuthDecorator(authConfig.Username, authConfig.Password) dec := utils.NewHTTPAuthDecorator(authConfig.Username, authConfig.Password)
factory.AddDecorator(dec) factory.AddDecorator(dec)
} }
@ -93,7 +93,7 @@ func (r *Session) GetRemoteHistory(imgID, registry string, token []string) ([]st
return nil, fmt.Errorf("Error while reading the http response: %s", err) return nil, fmt.Errorf("Error while reading the http response: %s", err)
} }
log.Debugf("Ancestry: %s", jsonString) logrus.Debugf("Ancestry: %s", jsonString)
history := new([]string) history := new([]string)
if err := json.Unmarshal(jsonString, history); err != nil { if err := json.Unmarshal(jsonString, history); err != nil {
return nil, err return nil, err
@ -169,7 +169,7 @@ func (r *Session) GetRemoteImageLayer(imgID, registry string, token []string, im
statusCode = 0 statusCode = 0
res, client, err = r.doRequest(req) res, client, err = r.doRequest(req)
if err != nil { if err != nil {
log.Debugf("Error contacting registry: %s", err) logrus.Debugf("Error contacting registry: %s", err)
if res != nil { if res != nil {
if res.Body != nil { if res.Body != nil {
res.Body.Close() res.Body.Close()
@ -193,10 +193,10 @@ func (r *Session) GetRemoteImageLayer(imgID, registry string, token []string, im
} }
if res.Header.Get("Accept-Ranges") == "bytes" && imgSize > 0 { if res.Header.Get("Accept-Ranges") == "bytes" && imgSize > 0 {
log.Debugf("server supports resume") logrus.Debugf("server supports resume")
return httputils.ResumableRequestReaderWithInitialResponse(client, req, 5, imgSize, res), nil return httputils.ResumableRequestReaderWithInitialResponse(client, req, 5, imgSize, res), nil
} }
log.Debugf("server doesn't support resume") logrus.Debugf("server doesn't support resume")
return res.Body, nil return res.Body, nil
} }
@ -219,7 +219,7 @@ func (r *Session) GetRemoteTags(registries []string, repository string, token []
return nil, err return nil, err
} }
log.Debugf("Got status code %d from %s", res.StatusCode, endpoint) logrus.Debugf("Got status code %d from %s", res.StatusCode, endpoint)
defer res.Body.Close() defer res.Body.Close()
if res.StatusCode != 200 && res.StatusCode != 404 { if res.StatusCode != 200 && res.StatusCode != 404 {
@ -259,7 +259,7 @@ func buildEndpointsList(headers []string, indexEp string) ([]string, error) {
func (r *Session) GetRepositoryData(remote string) (*RepositoryData, error) { func (r *Session) GetRepositoryData(remote string) (*RepositoryData, error) {
repositoryTarget := fmt.Sprintf("%srepositories/%s/images", r.indexEndpoint.VersionString(1), remote) repositoryTarget := fmt.Sprintf("%srepositories/%s/images", r.indexEndpoint.VersionString(1), remote)
log.Debugf("[registry] Calling GET %s", repositoryTarget) logrus.Debugf("[registry] Calling GET %s", repositoryTarget)
req, err := r.reqFactory.NewRequest("GET", repositoryTarget, nil) req, err := r.reqFactory.NewRequest("GET", repositoryTarget, nil)
if err != nil { if err != nil {
@ -285,7 +285,7 @@ func (r *Session) GetRepositoryData(remote string) (*RepositoryData, error) {
} else if res.StatusCode != 200 { } else if res.StatusCode != 200 {
errBody, err := ioutil.ReadAll(res.Body) errBody, err := ioutil.ReadAll(res.Body)
if err != nil { if err != nil {
log.Debugf("Error reading response body: %s", err) logrus.Debugf("Error reading response body: %s", err)
} }
return nil, utils.NewHTTPRequestError(fmt.Sprintf("Error: Status %d trying to pull repository %s: %q", res.StatusCode, remote, errBody), res) return nil, utils.NewHTTPRequestError(fmt.Sprintf("Error: Status %d trying to pull repository %s: %q", res.StatusCode, remote, errBody), res)
} }
@ -326,7 +326,7 @@ func (r *Session) GetRepositoryData(remote string) (*RepositoryData, error) {
func (r *Session) PushImageChecksumRegistry(imgData *ImgData, registry string, token []string) error { func (r *Session) PushImageChecksumRegistry(imgData *ImgData, registry string, token []string) error {
log.Debugf("[registry] Calling PUT %s", registry+"images/"+imgData.ID+"/checksum") logrus.Debugf("[registry] Calling PUT %s", registry+"images/"+imgData.ID+"/checksum")
req, err := r.reqFactory.NewRequest("PUT", registry+"images/"+imgData.ID+"/checksum", nil) req, err := r.reqFactory.NewRequest("PUT", registry+"images/"+imgData.ID+"/checksum", nil)
if err != nil { if err != nil {
@ -363,7 +363,7 @@ func (r *Session) PushImageChecksumRegistry(imgData *ImgData, registry string, t
// Push a local image to the registry // Push a local image to the registry
func (r *Session) PushImageJSONRegistry(imgData *ImgData, jsonRaw []byte, registry string, token []string) error { func (r *Session) PushImageJSONRegistry(imgData *ImgData, jsonRaw []byte, registry string, token []string) error {
log.Debugf("[registry] Calling PUT %s", registry+"images/"+imgData.ID+"/json") logrus.Debugf("[registry] Calling PUT %s", registry+"images/"+imgData.ID+"/json")
req, err := r.reqFactory.NewRequest("PUT", registry+"images/"+imgData.ID+"/json", bytes.NewReader(jsonRaw)) req, err := r.reqFactory.NewRequest("PUT", registry+"images/"+imgData.ID+"/json", bytes.NewReader(jsonRaw))
if err != nil { if err != nil {
@ -398,7 +398,7 @@ func (r *Session) PushImageJSONRegistry(imgData *ImgData, jsonRaw []byte, regist
func (r *Session) PushImageLayerRegistry(imgID string, layer io.Reader, registry string, token []string, jsonRaw []byte) (checksum string, checksumPayload string, err error) { func (r *Session) PushImageLayerRegistry(imgID string, layer io.Reader, registry string, token []string, jsonRaw []byte) (checksum string, checksumPayload string, err error) {
log.Debugf("[registry] Calling PUT %s", registry+"images/"+imgID+"/layer") logrus.Debugf("[registry] Calling PUT %s", registry+"images/"+imgID+"/layer")
tarsumLayer, err := tarsum.NewTarSum(layer, false, tarsum.Version0) tarsumLayer, err := tarsum.NewTarSum(layer, false, tarsum.Version0)
if err != nil { if err != nil {
@ -486,8 +486,8 @@ func (r *Session) PushImageJSONIndex(remote string, imgList []*ImgData, validate
suffix = "images" suffix = "images"
} }
u := fmt.Sprintf("%srepositories/%s/%s", r.indexEndpoint.VersionString(1), remote, suffix) u := fmt.Sprintf("%srepositories/%s/%s", r.indexEndpoint.VersionString(1), remote, suffix)
log.Debugf("[registry] PUT %s", u) logrus.Debugf("[registry] PUT %s", u)
log.Debugf("Image list pushed to index:\n%s", imgListJSON) logrus.Debugf("Image list pushed to index:\n%s", imgListJSON)
headers := map[string][]string{ headers := map[string][]string{
"Content-type": {"application/json"}, "Content-type": {"application/json"},
"X-Docker-Token": {"true"}, "X-Docker-Token": {"true"},
@ -507,7 +507,7 @@ func (r *Session) PushImageJSONIndex(remote string, imgList []*ImgData, validate
} }
res.Body.Close() res.Body.Close()
u = res.Header.Get("Location") u = res.Header.Get("Location")
log.Debugf("Redirected to %s", u) logrus.Debugf("Redirected to %s", u)
} }
defer res.Body.Close() defer res.Body.Close()
@ -520,13 +520,13 @@ func (r *Session) PushImageJSONIndex(remote string, imgList []*ImgData, validate
if res.StatusCode != 200 && res.StatusCode != 201 { if res.StatusCode != 200 && res.StatusCode != 201 {
errBody, err := ioutil.ReadAll(res.Body) errBody, err := ioutil.ReadAll(res.Body)
if err != nil { if err != nil {
log.Debugf("Error reading response body: %s", err) logrus.Debugf("Error reading response body: %s", err)
} }
return nil, utils.NewHTTPRequestError(fmt.Sprintf("Error: Status %d trying to push repository %s: %q", res.StatusCode, remote, errBody), res) return nil, utils.NewHTTPRequestError(fmt.Sprintf("Error: Status %d trying to push repository %s: %q", res.StatusCode, remote, errBody), res)
} }
if res.Header.Get("X-Docker-Token") != "" { if res.Header.Get("X-Docker-Token") != "" {
tokens = res.Header["X-Docker-Token"] tokens = res.Header["X-Docker-Token"]
log.Debugf("Auth token: %v", tokens) logrus.Debugf("Auth token: %v", tokens)
} else { } else {
return nil, fmt.Errorf("Index response didn't contain an access token") return nil, fmt.Errorf("Index response didn't contain an access token")
} }
@ -544,7 +544,7 @@ func (r *Session) PushImageJSONIndex(remote string, imgList []*ImgData, validate
if res.StatusCode != 204 { if res.StatusCode != 204 {
errBody, err := ioutil.ReadAll(res.Body) errBody, err := ioutil.ReadAll(res.Body)
if err != nil { if err != nil {
log.Debugf("Error reading response body: %s", err) logrus.Debugf("Error reading response body: %s", err)
} }
return nil, utils.NewHTTPRequestError(fmt.Sprintf("Error: Status %d trying to push checksums %s: %q", res.StatusCode, remote, errBody), res) return nil, utils.NewHTTPRequestError(fmt.Sprintf("Error: Status %d trying to push checksums %s: %q", res.StatusCode, remote, errBody), res)
} }
@ -578,7 +578,7 @@ func shouldRedirect(response *http.Response) bool {
} }
func (r *Session) SearchRepositories(term string) (*SearchResults, error) { func (r *Session) SearchRepositories(term string) (*SearchResults, error) {
log.Debugf("Index server: %s", r.indexEndpoint) logrus.Debugf("Index server: %s", r.indexEndpoint)
u := r.indexEndpoint.VersionString(1) + "search?q=" + url.QueryEscape(term) u := r.indexEndpoint.VersionString(1) + "search?q=" + url.QueryEscape(term)
req, err := r.reqFactory.NewRequest("GET", u, nil) req, err := r.reqFactory.NewRequest("GET", u, nil)
if err != nil { if err != nil {

View file

@ -9,7 +9,7 @@ import (
"net/http" "net/http"
"strconv" "strconv"
log "github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/distribution/digest" "github.com/docker/distribution/digest"
"github.com/docker/docker/registry/v2" "github.com/docker/docker/registry/v2"
"github.com/docker/docker/utils" "github.com/docker/docker/utils"
@ -57,7 +57,7 @@ func (r *Session) GetV2Authorization(ep *Endpoint, imageName string, readOnly bo
scopes = append(scopes, "push") scopes = append(scopes, "push")
} }
log.Debugf("Getting authorization for %s %s", imageName, scopes) logrus.Debugf("Getting authorization for %s %s", imageName, scopes)
return NewRequestAuthorization(r.GetAuthConfig(true), ep, "repository", imageName, scopes), nil return NewRequestAuthorization(r.GetAuthConfig(true), ep, "repository", imageName, scopes), nil
} }
@ -75,7 +75,7 @@ func (r *Session) GetV2ImageManifest(ep *Endpoint, imageName, tagName string, au
} }
method := "GET" method := "GET"
log.Debugf("[registry] Calling %q %s", method, routeURL) logrus.Debugf("[registry] Calling %q %s", method, routeURL)
req, err := r.reqFactory.NewRequest(method, routeURL, nil) req, err := r.reqFactory.NewRequest(method, routeURL, nil)
if err != nil { if err != nil {
@ -116,7 +116,7 @@ func (r *Session) HeadV2ImageBlob(ep *Endpoint, imageName, sumType, sum string,
} }
method := "HEAD" method := "HEAD"
log.Debugf("[registry] Calling %q %s", method, routeURL) logrus.Debugf("[registry] Calling %q %s", method, routeURL)
req, err := r.reqFactory.NewRequest(method, routeURL, nil) req, err := r.reqFactory.NewRequest(method, routeURL, nil)
if err != nil { if err != nil {
@ -151,7 +151,7 @@ func (r *Session) GetV2ImageBlob(ep *Endpoint, imageName, sumType, sum string, b
} }
method := "GET" method := "GET"
log.Debugf("[registry] Calling %q %s", method, routeURL) logrus.Debugf("[registry] Calling %q %s", method, routeURL)
req, err := r.reqFactory.NewRequest(method, routeURL, nil) req, err := r.reqFactory.NewRequest(method, routeURL, nil)
if err != nil { if err != nil {
return err return err
@ -182,7 +182,7 @@ func (r *Session) GetV2ImageBlobReader(ep *Endpoint, imageName, sumType, sum str
} }
method := "GET" method := "GET"
log.Debugf("[registry] Calling %q %s", method, routeURL) logrus.Debugf("[registry] Calling %q %s", method, routeURL)
req, err := r.reqFactory.NewRequest(method, routeURL, nil) req, err := r.reqFactory.NewRequest(method, routeURL, nil)
if err != nil { if err != nil {
return nil, 0, err return nil, 0, err
@ -219,7 +219,7 @@ func (r *Session) PutV2ImageBlob(ep *Endpoint, imageName, sumType, sumStr string
} }
method := "PUT" method := "PUT"
log.Debugf("[registry] Calling %q %s", method, location) logrus.Debugf("[registry] Calling %q %s", method, location)
req, err := r.reqFactory.NewRequest(method, location, ioutil.NopCloser(blobRdr)) req, err := r.reqFactory.NewRequest(method, location, ioutil.NopCloser(blobRdr))
if err != nil { if err != nil {
return err return err
@ -244,7 +244,7 @@ func (r *Session) PutV2ImageBlob(ep *Endpoint, imageName, sumType, sumStr string
if err != nil { if err != nil {
return err return err
} }
log.Debugf("Unexpected response from server: %q %#v", errBody, res.Header) logrus.Debugf("Unexpected response from server: %q %#v", errBody, res.Header)
return utils.NewHTTPRequestError(fmt.Sprintf("Server error: %d trying to push %s blob - %s:%s", res.StatusCode, imageName, sumType, sumStr), res) return utils.NewHTTPRequestError(fmt.Sprintf("Server error: %d trying to push %s blob - %s:%s", res.StatusCode, imageName, sumType, sumStr), res)
} }
@ -258,7 +258,7 @@ func (r *Session) initiateBlobUpload(ep *Endpoint, imageName string, auth *Reque
return "", err return "", err
} }
log.Debugf("[registry] Calling %q %s", "POST", routeURL) logrus.Debugf("[registry] Calling %q %s", "POST", routeURL)
req, err := r.reqFactory.NewRequest("POST", routeURL, nil) req, err := r.reqFactory.NewRequest("POST", routeURL, nil)
if err != nil { if err != nil {
return "", err return "", err
@ -285,7 +285,7 @@ func (r *Session) initiateBlobUpload(ep *Endpoint, imageName string, auth *Reque
return "", err return "", err
} }
log.Debugf("Unexpected response from server: %q %#v", errBody, res.Header) logrus.Debugf("Unexpected response from server: %q %#v", errBody, res.Header)
return "", utils.NewHTTPRequestError(fmt.Sprintf("Server error: unexpected %d response status trying to initiate upload of %s", res.StatusCode, imageName), res) return "", utils.NewHTTPRequestError(fmt.Sprintf("Server error: unexpected %d response status trying to initiate upload of %s", res.StatusCode, imageName), res)
} }
@ -304,7 +304,7 @@ func (r *Session) PutV2ImageManifest(ep *Endpoint, imageName, tagName string, si
} }
method := "PUT" method := "PUT"
log.Debugf("[registry] Calling %q %s", method, routeURL) logrus.Debugf("[registry] Calling %q %s", method, routeURL)
req, err := r.reqFactory.NewRequest(method, routeURL, bytes.NewReader(signedManifest)) req, err := r.reqFactory.NewRequest(method, routeURL, bytes.NewReader(signedManifest))
if err != nil { if err != nil {
return "", err return "", err
@ -327,7 +327,7 @@ func (r *Session) PutV2ImageManifest(ep *Endpoint, imageName, tagName string, si
if err != nil { if err != nil {
return "", err return "", err
} }
log.Debugf("Unexpected response from server: %q %#v", errBody, res.Header) logrus.Debugf("Unexpected response from server: %q %#v", errBody, res.Header)
return "", utils.NewHTTPRequestError(fmt.Sprintf("Server error: %d trying to push %s:%s manifest", res.StatusCode, imageName, tagName), res) return "", utils.NewHTTPRequestError(fmt.Sprintf("Server error: %d trying to push %s:%s manifest", res.StatusCode, imageName, tagName), res)
} }
@ -364,7 +364,7 @@ func (r *Session) GetV2RemoteTags(ep *Endpoint, imageName string, auth *RequestA
} }
method := "GET" method := "GET"
log.Debugf("[registry] Calling %q %s", method, routeURL) logrus.Debugf("[registry] Calling %q %s", method, routeURL)
req, err := r.reqFactory.NewRequest(method, routeURL, nil) req, err := r.reqFactory.NewRequest(method, routeURL, nil)
if err != nil { if err != nil {