github.com/rawahars/moby@v24.0.4+incompatible/distribution/repository.go (about) 1 package distribution 2 3 import ( 4 "context" 5 6 "github.com/docker/distribution" 7 "github.com/docker/distribution/reference" 8 "github.com/docker/docker/errdefs" 9 ) 10 11 // GetRepository returns a repository from the registry. 12 func GetRepository(ctx context.Context, ref reference.Named, config *ImagePullConfig) (repository distribution.Repository, lastError error) { 13 repoInfo, err := config.RegistryService.ResolveRepository(ref) 14 if err != nil { 15 return nil, errdefs.InvalidParameter(err) 16 } 17 // makes sure name is not empty or `scratch` 18 if err := validateRepoName(repoInfo.Name); err != nil { 19 return nil, errdefs.InvalidParameter(err) 20 } 21 22 endpoints, err := config.RegistryService.LookupPullEndpoints(reference.Domain(repoInfo.Name)) 23 if err != nil { 24 return nil, err 25 } 26 27 for _, endpoint := range endpoints { 28 repository, lastError = newRepository(ctx, repoInfo, endpoint, nil, config.AuthConfig, "pull") 29 if lastError == nil { 30 break 31 } 32 } 33 return repository, lastError 34 }