mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
registry.loginV2(): minor cleanup
just some minor cleaning up; construct the endpoint-path once instead of twice, and grouping all variable declarations at the start. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
bb23f1bf61
commit
ac84f1b55f
1 changed files with 8 additions and 9 deletions
|
@ -77,22 +77,21 @@ func (err fallbackError) Error() string {
|
||||||
// endpoint will be pinged to get authorization challenges. These challenges
|
// endpoint will be pinged to get authorization challenges. These challenges
|
||||||
// will be used to authenticate against the registry to validate credentials.
|
// will be used to authenticate against the registry to validate credentials.
|
||||||
func loginV2(authConfig *types.AuthConfig, endpoint APIEndpoint, userAgent string) (string, string, error) {
|
func loginV2(authConfig *types.AuthConfig, endpoint APIEndpoint, userAgent string) (string, string, error) {
|
||||||
logrus.Debugf("attempting v2 login to registry endpoint %s", strings.TrimRight(endpoint.URL.String(), "/")+"/v2/")
|
var (
|
||||||
|
endpointStr = strings.TrimRight(endpoint.URL.String(), "/") + "/v2/"
|
||||||
|
modifiers = Headers(userAgent, nil)
|
||||||
|
authTransport = transport.NewTransport(NewTransport(endpoint.TLSConfig), modifiers...)
|
||||||
|
credentialAuthConfig = *authConfig
|
||||||
|
creds = loginCredentialStore{authConfig: &credentialAuthConfig}
|
||||||
|
)
|
||||||
|
|
||||||
modifiers := Headers(userAgent, nil)
|
logrus.Debugf("attempting v2 login to registry endpoint %s", endpointStr)
|
||||||
authTransport := transport.NewTransport(NewTransport(endpoint.TLSConfig), modifiers...)
|
|
||||||
|
|
||||||
credentialAuthConfig := *authConfig
|
|
||||||
creds := loginCredentialStore{
|
|
||||||
authConfig: &credentialAuthConfig,
|
|
||||||
}
|
|
||||||
|
|
||||||
loginClient, foundV2, err := v2AuthHTTPClient(endpoint.URL, authTransport, modifiers, creds, nil)
|
loginClient, foundV2, err := v2AuthHTTPClient(endpoint.URL, authTransport, modifiers, creds, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
endpointStr := strings.TrimRight(endpoint.URL.String(), "/") + "/v2/"
|
|
||||||
req, err := http.NewRequest(http.MethodGet, endpointStr, nil)
|
req, err := http.NewRequest(http.MethodGet, endpointStr, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !foundV2 {
|
if !foundV2 {
|
||||||
|
|
Loading…
Reference in a new issue