MCPcopy Index your code
hub / github.com/containers/toolbox / pullImage

Function pullImage

src/cmd/create.go:667–755  ·  view source on GitHub ↗
(image, release, authFile string)

Source from the content-addressed store, hash-verified

665}
666
667func pullImage(image, release, authFile string) (bool, error) {
668 if ok := utils.ImageReferenceCanBeID(image); ok {
669 logrus.Debugf("Looking up image %s", image)
670 if _, err := podman.ImageExists(image); err == nil {
671 return true, nil
672 }
673 }
674
675 hasDomain := utils.ImageReferenceHasDomain(image)
676
677 if !hasDomain {
678 imageLocal := "localhost/" + image
679 logrus.Debugf("Looking up image %s", imageLocal)
680
681 if _, err := podman.ImageExists(imageLocal); err == nil {
682 return true, nil
683 }
684 }
685
686 var imageFull string
687
688 if hasDomain {
689 imageFull = image
690 } else {
691 var err error
692 imageFull, err = utils.GetFullyQualifiedImageFromDistros(image, release)
693 if err != nil {
694 return false, fmt.Errorf("image %s not found in local storage and known registries", image)
695 }
696 }
697
698 logrus.Debugf("Looking up image %s", imageFull)
699 if _, err := podman.ImageExists(imageFull); err == nil {
700 return true, nil
701 }
702
703 domain := utils.ImageReferenceGetDomain(imageFull)
704 if domain == "" {
705 panicMsg := fmt.Sprintf("failed to get domain from %s", imageFull)
706 panic(panicMsg)
707 }
708
709 promptForDownload := true
710 var shouldPullImage bool
711
712 if rootFlags.assumeYes || domain == "localhost" {
713 promptForDownload = false
714 shouldPullImage = true
715 }
716
717 if promptForDownload {
718 if !term.IsTerminal(os.Stdin) || !term.IsTerminal(os.Stdout) {
719 var builder strings.Builder
720 fmt.Fprintf(&builder, "image required to create Toolbx container.\n")
721 fmt.Fprintf(&builder, "Use option '--assumeyes' to download the image.\n")
722 fmt.Fprintf(&builder, "Run '%s --help' for usage.", executableBase)
723
724 errMsg := builder.String()

Callers 1

createContainerFunction · 0.85

Calls 1

showPromptForDownloadFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…