|
@@ -133,35 +133,12 @@ func (i *ImageService) pullImageWithReference(ctx context.Context, ref reference
|
|
|
|
|
|
// GetRepository returns a repository from the registry.
|
|
// GetRepository returns a repository from the registry.
|
|
func (i *ImageService) GetRepository(ctx context.Context, ref reference.Named, authConfig *types.AuthConfig) (dist.Repository, error) {
|
|
func (i *ImageService) GetRepository(ctx context.Context, ref reference.Named, authConfig *types.AuthConfig) (dist.Repository, error) {
|
|
- // get repository info
|
|
|
|
- repoInfo, err := i.registryService.ResolveRepository(ref)
|
|
|
|
- if err != nil {
|
|
|
|
- return nil, errdefs.InvalidParameter(err)
|
|
|
|
- }
|
|
|
|
- // makes sure name is not empty or `scratch`
|
|
|
|
- if err := distribution.ValidateRepoName(repoInfo.Name); err != nil {
|
|
|
|
- return nil, errdefs.InvalidParameter(err)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // get endpoints
|
|
|
|
- endpoints, err := i.registryService.LookupPullEndpoints(reference.Domain(repoInfo.Name))
|
|
|
|
- if err != nil {
|
|
|
|
- return nil, err
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // retrieve repository
|
|
|
|
- var (
|
|
|
|
- repository dist.Repository
|
|
|
|
- lastError error
|
|
|
|
- )
|
|
|
|
-
|
|
|
|
- for _, endpoint := range endpoints {
|
|
|
|
- repository, lastError = distribution.NewV2Repository(ctx, repoInfo, endpoint, nil, authConfig, "pull")
|
|
|
|
- if lastError == nil {
|
|
|
|
- break
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return repository, lastError
|
|
|
|
|
|
+ return distribution.GetRepository(ctx, ref, &distribution.ImagePullConfig{
|
|
|
|
+ Config: distribution.Config{
|
|
|
|
+ AuthConfig: authConfig,
|
|
|
|
+ RegistryService: i.registryService,
|
|
|
|
+ },
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
func tempLease(ctx context.Context, mgr leases.Manager) (context.Context, func(context.Context) error, error) {
|
|
func tempLease(ctx context.Context, mgr leases.Manager) (context.Context, func(context.Context) error, error) {
|