|
@@ -15,10 +15,8 @@ import (
|
|
|
"github.com/sirupsen/logrus"
|
|
|
)
|
|
|
|
|
|
-const (
|
|
|
- // AuthClientID is used the ClientID used for the token server
|
|
|
- AuthClientID = "docker"
|
|
|
-)
|
|
|
+// AuthClientID is used the ClientID used for the token server
|
|
|
+const AuthClientID = "docker"
|
|
|
|
|
|
type loginCredentialStore struct {
|
|
|
authConfig *types.AuthConfig
|
|
@@ -109,8 +107,7 @@ func loginV2(authConfig *types.AuthConfig, endpoint APIEndpoint, userAgent strin
|
|
|
}
|
|
|
|
|
|
// TODO(dmcgowan): Attempt to further interpret result, status code and error code string
|
|
|
- err = errors.Errorf("login attempt to %s failed with status: %d %s", endpointStr, resp.StatusCode, http.StatusText(resp.StatusCode))
|
|
|
- return "", "", err
|
|
|
+ return "", "", errors.Errorf("login attempt to %s failed with status: %d %s", endpointStr, resp.StatusCode, http.StatusText(resp.StatusCode))
|
|
|
}
|
|
|
|
|
|
func v2AuthHTTPClient(endpoint *url.URL, authTransport http.RoundTripper, modifiers []transport.RequestModifier, creds auth.CredentialStore, scopes []auth.Scope) (*http.Client, error) {
|
|
@@ -129,10 +126,9 @@ func v2AuthHTTPClient(endpoint *url.URL, authTransport http.RoundTripper, modifi
|
|
|
tokenHandler := auth.NewTokenHandlerWithOptions(tokenHandlerOptions)
|
|
|
basicHandler := auth.NewBasicHandler(creds)
|
|
|
modifiers = append(modifiers, auth.NewAuthorizer(challengeManager, tokenHandler, basicHandler))
|
|
|
- tr := transport.NewTransport(authTransport, modifiers...)
|
|
|
|
|
|
return &http.Client{
|
|
|
- Transport: tr,
|
|
|
+ Transport: transport.NewTransport(authTransport, modifiers...),
|
|
|
Timeout: 15 * time.Second,
|
|
|
}, nil
|
|
|
}
|
|
@@ -146,10 +142,7 @@ func ConvertToHostname(url string) string {
|
|
|
} else if strings.HasPrefix(url, "https://") {
|
|
|
stripped = strings.TrimPrefix(url, "https://")
|
|
|
}
|
|
|
-
|
|
|
- nameParts := strings.SplitN(stripped, "/", 2)
|
|
|
-
|
|
|
- return nameParts[0]
|
|
|
+ return strings.SplitN(stripped, "/", 2)[0]
|
|
|
}
|
|
|
|
|
|
// ResolveAuthConfig matches an auth configuration to a server address or a URL
|