@@ -421,7 +421,11 @@ func (r *Runtime) copyFromRegistry(ctx context.Context, ref types.ImageReference
421421 }
422422
423423 if ! options .AllTags {
424- return r .copySingleImageFromRegistry (ctx , inputName , pullPolicy , options )
424+ pulled , err := r .copySingleImageFromRegistry (ctx , inputName , pullPolicy , options )
425+ if err != nil {
426+ return nil , err
427+ }
428+ return []string {pulled }, err
425429 }
426430
427431 // Copy all tags
@@ -447,7 +451,7 @@ func (r *Runtime) copyFromRegistry(ctx context.Context, ref types.ImageReference
447451 if err != nil {
448452 return nil , err
449453 }
450- pulledIDs = append (pulledIDs , pulled ... )
454+ pulledIDs = append (pulledIDs , pulled )
451455 }
452456
453457 return pulledIDs , nil
@@ -503,11 +507,11 @@ func (r *Runtime) imageIDForManifest(manifestBytes []byte, sys *types.SystemCont
503507
504508// copySingleImageFromRegistry pulls the specified, possibly unqualified, name
505509// from a registry. On successful pull it returns the ID of the image in local
506- // storage.
507- func (r * Runtime ) copySingleImageFromRegistry (ctx context.Context , imageName string , pullPolicy config.PullPolicy , options * PullOptions ) ([] string , error ) { //nolint:gocyclo
510+ // storage (or, FIXME, a name/ID? that could be resolved in local storage)
511+ func (r * Runtime ) copySingleImageFromRegistry (ctx context.Context , imageName string , pullPolicy config.PullPolicy , options * PullOptions ) (string , error ) { //nolint:gocyclo
508512 // Sanity check.
509513 if err := pullPolicy .Validate (); err != nil {
510- return nil , err
514+ return "" , err
511515 }
512516
513517 var (
@@ -570,23 +574,23 @@ func (r *Runtime) copySingleImageFromRegistry(ctx context.Context, imageName str
570574 if pullPolicy == config .PullPolicyNever {
571575 if localImage != nil {
572576 logrus .Debugf ("Pull policy %q and %s resolved to local image %s" , pullPolicy , imageName , resolvedImageName )
573- return [] string { resolvedImageName } , nil
577+ return resolvedImageName , nil
574578 }
575579 logrus .Debugf ("Pull policy %q but no local image has been found for %s" , pullPolicy , imageName )
576- return nil , fmt .Errorf ("%s: %w" , imageName , storage .ErrImageUnknown )
580+ return "" , fmt .Errorf ("%s: %w" , imageName , storage .ErrImageUnknown )
577581 }
578582
579583 if pullPolicy == config .PullPolicyMissing && localImage != nil {
580- return [] string { resolvedImageName } , nil
584+ return resolvedImageName , nil
581585 }
582586
583587 // If we looked up the image by ID, we cannot really pull from anywhere.
584588 if localImage != nil && strings .HasPrefix (localImage .ID (), imageName ) {
585589 switch pullPolicy {
586590 case config .PullPolicyAlways :
587- return nil , fmt .Errorf ("pull policy is always but image has been referred to by ID (%s)" , imageName )
591+ return "" , fmt .Errorf ("pull policy is always but image has been referred to by ID (%s)" , imageName )
588592 default :
589- return [] string { resolvedImageName } , nil
593+ return resolvedImageName , nil
590594 }
591595 }
592596
@@ -611,9 +615,9 @@ func (r *Runtime) copySingleImageFromRegistry(ctx context.Context, imageName str
611615 resolved , err := shortnames .Resolve (sys , imageName )
612616 if err != nil {
613617 if localImage != nil && pullPolicy == config .PullPolicyNewer {
614- return [] string { resolvedImageName } , nil
618+ return resolvedImageName , nil
615619 }
616- return nil , err
620+ return "" , err
617621 }
618622
619623 // NOTE: Below we print the description from the short-name resolution.
@@ -645,7 +649,7 @@ func (r *Runtime) copySingleImageFromRegistry(ctx context.Context, imageName str
645649 }
646650 c , err := r .newCopier (& options .CopyOptions )
647651 if err != nil {
648- return nil , err
652+ return "" , err
649653 }
650654 defer c .Close ()
651655
@@ -655,7 +659,7 @@ func (r *Runtime) copySingleImageFromRegistry(ctx context.Context, imageName str
655659 logrus .Debugf ("Attempting to pull candidate %s for %s" , candidateString , imageName )
656660 srcRef , err := registryTransport .NewReference (candidate .Value )
657661 if err != nil {
658- return nil , err
662+ return "" , err
659663 }
660664
661665 if pullPolicy == config .PullPolicyNewer && localImage != nil {
@@ -673,15 +677,15 @@ func (r *Runtime) copySingleImageFromRegistry(ctx context.Context, imageName str
673677
674678 destRef , err := storageTransport .Transport .ParseStoreReference (r .store , candidate .Value .String ())
675679 if err != nil {
676- return nil , err
680+ return "" , err
677681 }
678682
679683 if err := writeDesc (); err != nil {
680- return nil , err
684+ return "" , err
681685 }
682686 if options .Writer != nil {
683687 if _ , err := io .WriteString (options .Writer , fmt .Sprintf ("Trying to pull %s...\n " , candidateString )); err != nil {
684- return nil , err
688+ return "" , err
685689 }
686690 }
687691 var manifestBytes []byte
@@ -700,18 +704,18 @@ func (r *Runtime) copySingleImageFromRegistry(ctx context.Context, imageName str
700704 logrus .Debugf ("Pulled candidate %s successfully" , candidateString )
701705 ids , err := r .imageIDForManifest (manifestBytes , sys )
702706 if err != nil {
703- return nil , err
707+ return "" , err
704708 }
705- return [] string { ids } , nil
709+ return ids , nil
706710 }
707711
708712 if localImage != nil && pullPolicy == config .PullPolicyNewer {
709- return [] string { resolvedImageName } , nil
713+ return resolvedImageName , nil
710714 }
711715
712716 if len (pullErrors ) == 0 {
713- return nil , fmt .Errorf ("internal error: no image pulled (pull policy %s)" , pullPolicy )
717+ return "" , fmt .Errorf ("internal error: no image pulled (pull policy %s)" , pullPolicy )
714718 }
715719
716- return nil , resolved .FormatPullErrors (pullErrors )
720+ return "" , resolved .FormatPullErrors (pullErrors )
717721}
0 commit comments