Update login to use token handling code from distribution #20832
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR lays the groundwork for a future PR to add OAuth registry authentication (see distribution/distribution#1418 and distribution/distribution#1475). Before this can happen,
docker login
needs to use the token handling code indocker/distribution
instead of using a separate implementation.The main purpose of this PR is to make
docker login
use token handling logic defined indocker/distribution
, like push and pull already do. However, there's a fair amount of cleanup here as well. The idea is to simplify thelogin
code and clean up the technical debt here so the upcoming PR to add OAuth will be a relatively simple change that can be easily reviewed.The main changes here are:
LookupPullEndpoints
to take a hostname instead parsing a full image reference to extract the hostnameEndpoint
toV1Endpoint
to make clear it is only used in v1 flowsgetToken
function that duplicates token handling code in thegithub.com/docker/distribution/registry/client/auth
auth package. Use the vendored code instead.This was originally written by @dmcgowan. I am submitting the PR on his behalf (with a few minor edits of my own), since he is away for the next few days.