refactor and simplify various code-paths related to distribution / authentication #49696
Merged
thaJeztah merged 15 commits intomoby:masterfrom Mar 28, 2025
Merged
refactor and simplify various code-paths related to distribution / authentication #49696thaJeztah merged 15 commits intomoby:masterfrom
thaJeztah merged 15 commits intomoby:masterfrom
Conversation
84dec33 to
9f09cc2
Compare
robmry
approved these changes
Mar 27, 2025
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
thaJeztah
commented
Mar 28, 2025
distribution/pull_v2.go
Outdated
| // TODO(thaJeztah): do we need p.repoInfo at all, as it would probably be same as ref? | ||
| p.repo, err = newRepository(ctx, p.repoInfo.Name, p.endpoint, p.config.MetaHeaders, p.config.AuthConfig, "pull") | ||
| p.repo, err = newRepository(ctx, p.repoName, p.endpoint, p.config.MetaHeaders, p.config.AuthConfig, "pull") |
Member
Author
There was a problem hiding this comment.
Looks like I forgot to update the comment here; let me do a quick rebase and fix that
This constructor only uses the name / reference, and doesn't use any of the other properties provided in RepositoryInfo. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This type only uses the name / reference, and doesn't use any of the other properties provided in RepositoryInfo. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This constructor only uses the name / reference, and doesn't use any of the other properties provided in RepositoryInfo. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The callback only used the name / reference Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
we're only consuming the name returned. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
[Service.ResolveRepository] is a shallow wrapper around [newRepositoryInfo], from which we only consume the `Name` field. That field is a direct result of `reference.TrimNamed`, so we can replace this with that. [Service.ResolveRepository]: https://github.com/moby/moby/blob/ecb03c4cdae6f323150fc11b303dcc5dc4d82416/registry/service.go#L106-L111 [newRepositoryInfo]: https://github.com/moby/moby/blob/ecb03c4cdae6f323150fc11b303dcc5dc4d82416/registry/config.go#L392-L408 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This constructor only uses the name / reference, and doesn't use any of the other properties provided in RepositoryInfo. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
[Service.ResolveRepository] is a shallow wrapper around [newRepositoryInfo], from which we only consume the `Name` field. That field is a direct result of `reference.TrimNamed`, so we can replace this with that. [Service.ResolveRepository]: https://github.com/moby/moby/blob/ecb03c4cdae6f323150fc11b303dcc5dc4d82416/registry/service.go#L106-L111 [newRepositoryInfo]: https://github.com/moby/moby/blob/ecb03c4cdae6f323150fc11b303dcc5dc4d82416/registry/config.go#L392-L408 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
[Service.ResolveRepository] is a shallow wrapper around [newRepositoryInfo], from which we only consume the `Name` field. That field is a direct result of `reference.TrimNamed`, so we can replace this with that. [Service.ResolveRepository]: https://github.com/moby/moby/blob/ecb03c4cdae6f323150fc11b303dcc5dc4d82416/registry/service.go#L106-L111 [newRepositoryInfo]: https://github.com/moby/moby/blob/ecb03c4cdae6f323150fc11b303dcc5dc4d82416/registry/config.go#L392-L408 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
It's not called anywhere, so we can remove it from this interface. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Simplify how we lookup auth-config, as we don't need the additional information provided by RepositoryInfo. There's still more layers to peel off, which will be done in follow-ups. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
inline a simplified version of "newIndexInfo" without handling of insecure registries and mirrors, as we don't need that information to resolve the auth-config. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
While it's generally better to define interfaces locally, this one now duplicated distribution.RegistryResolver, and it's passed on to other types which expect that interface. Remove this (un-exported) interface to make it easier to discover what's used where. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
9f09cc2 to
ec7fe73
Compare
neersighted
approved these changes
Mar 28, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
distribution: remove vars that shadowed imports or types
distribution: newRepository: don't require RepositoryInfo
This constructor only uses the name / reference, and doesn't
use any of the other properties provided in RepositoryInfo.
distribution: layerDescriptor: don't require RepositoryInfo
This type only uses the name / reference, and doesn't use any of the
other properties provided in RepositoryInfo.
distribution: newPuller: don't require RepositoryInfo
This constructor only uses the name / reference, and doesn't
use any of the other properties provided in RepositoryInfo
distribution: pullEndpoints: don't require RepositoryInfo
The callback only used the name / reference
distribution: pullEndpoints: don't return RepositoryInfo
we're only consuming the name returned.
distribution: pullEndpoints: skip using Service.ResolveRepository
Service.ResolveRepository is a shallow wrapper around newRepositoryInfo,
from which we only consume the
Namefield. That field is a direct resultof
reference.TrimNamed, so we can replace this with that.distribution; newPusher: don't require RepositoryInfo
This constructor only uses the name / reference, and doesn't
use any of the other properties provided in RepositoryInfo.
distribution: Push: skip using Service.ResolveRepository
Service.ResolveRepository is a shallow wrapper around newRepositoryInfo,
from which we only consume the
Namefield. That field is a direct resultof
reference.TrimNamed, so we can replace this with that.distribution: GetRepositories skip using Service.ResolveRepository
Service.ResolveRepository is a shallow wrapper around newRepositoryInfo,
from which we only consume the
Namefield. That field is a direct resultof
reference.TrimNamed, so we can replace this with that.daemon/containerd: registryResolver: remove IsInsecureRegistry
It's not called anywhere, so we can remove it from this interface.
lookup auth-config without depending on RepositoryInfo
Simplify how we lookup auth-config, as we don't need the
additional information provided by RepositoryInfo. There's
still more layers to peel off, which will be done in follow-ups.
registry: ResolveAuthConfig: inline newIndexInfo code
inline a simplified version of "newIndexInfo" without handling of
insecure registries and mirrors, as we don't need that information
to resolve the auth-config.
daemon/containerd: remove registryResolver interface
While it's generally better to define interfaces locally, this one
now duplicated distribution.RegistryResolver, and it's passed on
to other types which expect that interface.
Remove this (un-exported) interface to make it easier to discover
what's used where.
distribution: pushDescriptor: rename repoInfo to repoName
- Human readable description for the release notes
- A picture of a cute animal (not mandatory but encouraged)