Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] function RegistryLogin in client package has incorrect logic #1030

Closed
allencloud opened this issue Apr 2, 2018 · 0 comments · Fixed by #1044
Closed

[bug] function RegistryLogin in client package has incorrect logic #1030

allencloud opened this issue Apr 2, 2018 · 0 comments · Fixed by #1044
Assignees
Labels
areas/log kind/bug This is bug report for project

Comments

@allencloud
Copy link
Collaborator

Ⅰ. Issue Description

When I was reviewing code in #1015, I found in master, the code following has incorrect logic:

// RegistryLogin authenticates the server with a given registry to login.
func (client *APIClient) RegistryLogin(ctx context.Context, auth *types.AuthConfig) (*types.AuthResponse, error) {
	resp, err := client.post(ctx, "/auth", nil, auth, nil)
	if err != nil || resp.StatusCode == http.StatusUnauthorized {
		return nil, err
	}

	authResp := &types.AuthResponse{}
	err = decodeBody(authResp, resp.Body)
	ensureCloseReader(resp)

	return authResp, err

In code above, when err == nil, and resp.StatusCode == http.StatusUnauthorized, code will return nil, nil. I don't think this is reasonable. @Ace-Tang

@pouchrobot pouchrobot added areas/log kind/bug This is bug report for project labels Apr 2, 2018
Ace-Tang added a commit that referenced this issue Apr 3, 2018
remove statuscode compare, since if login get unauthorized
error, http post will get a nil Response.

Fixes: #1030.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
areas/log kind/bug This is bug report for project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants