mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
distribution: Push: skip using Service.ResolveRepository
[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]:ecb03c4cda/registry/service.go (L106-L111)[newRepositoryInfo]:ecb03c4cda/registry/config.go (L392-L408)Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -21,22 +21,18 @@ const compressionBufSize = 32768
|
||||
func Push(ctx context.Context, ref reference.Named, config *ImagePushConfig) error {
|
||||
// FIXME: Allow to interrupt current push when new push of same image is done.
|
||||
|
||||
// Resolve the Repository name from fqn to RepositoryInfo
|
||||
repoInfo, err := config.RegistryService.ResolveRepository(ref)
|
||||
repoName := reference.TrimNamed(ref)
|
||||
|
||||
endpoints, err := config.RegistryService.LookupPushEndpoints(reference.Domain(repoName))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
endpoints, err := config.RegistryService.LookupPushEndpoints(reference.Domain(repoInfo.Name))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
progress.Messagef(config.ProgressOutput, "", "The push refers to repository [%s]", repoName.Name())
|
||||
|
||||
progress.Messagef(config.ProgressOutput, "", "The push refers to repository [%s]", repoInfo.Name.Name())
|
||||
|
||||
associations := config.ReferenceStore.ReferencesByName(repoInfo.Name)
|
||||
associations := config.ReferenceStore.ReferencesByName(repoName)
|
||||
if len(associations) == 0 {
|
||||
return fmt.Errorf("An image does not exist locally with the tag: %s", reference.FamiliarName(repoInfo.Name))
|
||||
return fmt.Errorf("An image does not exist locally with the tag: %s", reference.FamiliarName(repoName))
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -56,9 +52,9 @@ func Push(ctx context.Context, ref reference.Named, config *ImagePushConfig) err
|
||||
}
|
||||
}
|
||||
|
||||
log.G(ctx).Debugf("Trying to push %s to %s", repoInfo.Name.Name(), endpoint.URL)
|
||||
log.G(ctx).Debugf("Trying to push %s to %s", repoName.Name(), endpoint.URL)
|
||||
|
||||
if err := newPusher(ref, endpoint, repoInfo.Name, config).push(ctx); err != nil {
|
||||
if err := newPusher(ref, endpoint, repoName, config).push(ctx); err != nil {
|
||||
// Was this push cancelled? If so, don't try to fall
|
||||
// back.
|
||||
select {
|
||||
@@ -84,12 +80,12 @@ func Push(ctx context.Context, ref reference.Named, config *ImagePushConfig) err
|
||||
return err
|
||||
}
|
||||
|
||||
config.ImageEventLogger(ctx, reference.FamiliarString(ref), reference.FamiliarName(repoInfo.Name), events.ActionPush)
|
||||
config.ImageEventLogger(ctx, reference.FamiliarString(ref), reference.FamiliarName(repoName), events.ActionPush)
|
||||
return nil
|
||||
}
|
||||
|
||||
if lastErr == nil {
|
||||
lastErr = fmt.Errorf("no endpoints found for %s", repoInfo.Name.Name())
|
||||
lastErr = fmt.Errorf("no endpoints found for %s", repoName.Name())
|
||||
}
|
||||
return lastErr
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user