"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "vendor/github.com/containers/common/libimage/pull.go" between
podman-3.2.2.tar.gz and podman-3.2.3.tar.gz

About: podman (previous name "libpod") provides a library for applications looking to use the Container Pod concept, popularized by Kubernetes. Podman manages pods, containers, container images, and container volumes.

pull.go  (podman-3.2.2):pull.go  (podman-3.2.3)
skipping to change at line 64 skipping to change at line 64
var possiblyUnqualifiedName string // used for short-name resolution var possiblyUnqualifiedName string // used for short-name resolution
ref, err := alltransports.ParseImageName(name) ref, err := alltransports.ParseImageName(name)
if err != nil { if err != nil {
// If the image clearly refers to a local one, we can look it up directly. // If the image clearly refers to a local one, we can look it up directly.
// In fact, we need to since they are not parseable. // In fact, we need to since they are not parseable.
if strings.HasPrefix(name, "sha256:") || (len(name) == 64 && !str ings.ContainsAny(name, "/.:@")) { if strings.HasPrefix(name, "sha256:") || (len(name) == 64 && !str ings.ContainsAny(name, "/.:@")) {
if pullPolicy == config.PullPolicyAlways { if pullPolicy == config.PullPolicyAlways {
return nil, errors.Errorf("pull policy is always but image has been referred to by ID (%s)", name) return nil, errors.Errorf("pull policy is always but image has been referred to by ID (%s)", name)
} }
local, _, err := r.LookupImage(name, nil) local, _, err := r.LookupImage(name, &LookupImageOptions{ IgnorePlatform: true})
if err != nil { if err != nil {
return nil, err return nil, err
} }
return []*Image{local}, err return []*Image{local}, err
} }
// If the input does not include a transport assume it refers // If the input does not include a transport assume it refers
// to a registry. // to a registry.
dockerRef, dockerErr := alltransports.ParseImageName("docker://" + name) dockerRef, dockerErr := alltransports.ParseImageName("docker://" + name)
if dockerErr != nil { if dockerErr != nil {
skipping to change at line 96 skipping to change at line 96
return nil, errors.New("internal error: unexpected nil re ference") return nil, errors.New("internal error: unexpected nil re ference")
} }
possiblyUnqualifiedName = named.String() possiblyUnqualifiedName = named.String()
} }
if options.AllTags && ref.Transport().Name() != registryTransport.Transpo rt.Name() { if options.AllTags && ref.Transport().Name() != registryTransport.Transpo rt.Name() {
return nil, errors.Errorf("pulling all tags is not supported for %s transport", ref.Transport().Name()) return nil, errors.Errorf("pulling all tags is not supported for %s transport", ref.Transport().Name())
} }
if r.eventChannel != nil { if r.eventChannel != nil {
r.writeEvent(&Event{ID: "", Name: name, Time: time.Now(), Type: E ventTypeImagePull}) defer r.writeEvent(&Event{ID: "", Name: name, Time: time.Now(), T ype: EventTypeImagePull})
} }
// Some callers may set the platform via the system context at creation // Some callers may set the platform via the system context at creation
// time of the runtime. We need this information to decide whether we // time of the runtime. We need this information to decide whether we
// need to enforce pulling from a registry (see // need to enforce pulling from a registry (see
// containers/podman/issues/10682). // containers/podman/issues/10682).
if options.Architecture == "" { if options.Architecture == "" {
options.Architecture = r.systemContext.ArchitectureChoice options.Architecture = r.systemContext.ArchitectureChoice
} }
if options.OS == "" { if options.OS == "" {
skipping to change at line 139 skipping to change at line 139
// ALL OTHER TRANSPORTS // ALL OTHER TRANSPORTS
default: default:
pulledImages, pullError = r.copyFromDefault(ctx, ref, &options.Co pyOptions) pulledImages, pullError = r.copyFromDefault(ctx, ref, &options.Co pyOptions)
} }
if pullError != nil { if pullError != nil {
return nil, pullError return nil, pullError
} }
localImages := []*Image{} localImages := []*Image{}
lookupOptions := &LookupImageOptions{IgnorePlatform: true}
for _, name := range pulledImages { for _, name := range pulledImages {
local, _, err := r.LookupImage(name, lookupOptions) local, _, err := r.LookupImage(name, &LookupImageOptions{IgnorePl atform: true})
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "error locating pulled imag e %q name in containers storage", name) return nil, errors.Wrapf(err, "error locating pulled imag e %q name in containers storage", name)
} }
localImages = append(localImages, local) localImages = append(localImages, local)
} }
return localImages, pullError return localImages, pullError
} }
// copyFromDefault is the default copier for a number of transports. Other // copyFromDefault is the default copier for a number of transports. Other
skipping to change at line 377 skipping to change at line 376
} }
// If the local image is corrupted, we need to repull it. // If the local image is corrupted, we need to repull it.
if localImage != nil { if localImage != nil {
if err := localImage.isCorrupted(imageName); err != nil { if err := localImage.isCorrupted(imageName); err != nil {
logrus.Error(err) logrus.Error(err)
localImage = nil localImage = nil
} }
} }
// Unless the pull policy is "always", we must pessimistically assume customPlatform := false
// that the local image has an invalid architecture (see if len(options.Architecture)+len(options.OS)+len(options.Variant) > 0 {
// containers/podman/issues/10682). Hence, whenever the user requests customPlatform = true
// a custom platform, set the pull policy to "always" to make sure // Unless the pull policy is "always", we must pessimistically as
// we're pulling down the image. sume
// // that the local image has an invalid architecture (see
// NOTE that this is will even override --pull={false,never}. This is // containers/podman/issues/10682). Hence, whenever the user req
// very likely a bug but a consistent one in Podman/Buildah and should uests
// be addressed at a later point. // a custom platform, set the pull policy to "always" to make sur
if pullPolicy != config.PullPolicyAlways && len(options.Architecture)+len e
(options.OS)+len(options.Variant) > 0 { // we're pulling down the image.
logrus.Debugf("Enforcing pull policy to %q to support custom plat //
form (arch: %q, os: %q, variant: %q)", "always", options.Architecture, options.O // NOTE that this is will even override --pull={false,never}. Th
S, options.Variant) is is
pullPolicy = config.PullPolicyAlways // very likely a bug but a consistent one in Podman/Buildah and s
hould
// be addressed at a later point.
if pullPolicy != config.PullPolicyAlways {
switch {
// User input clearly refer to a local image.
case strings.HasPrefix(imageName, "localhost/"):
logrus.Debugf("Enforcing pull policy to %q to sup
port custom platform (arch: %q, os: %q, variant: %q)", "never", options.Architec
ture, options.OS, options.Variant)
pullPolicy = config.PullPolicyNever
// Image resolved to a local one, so let's still have a
// look at the registries or aliases but use it
// otherwise.
case strings.HasPrefix(resolvedImageName, "localhost/"):
logrus.Debugf("Enforcing pull policy to %q to sup
port custom platform (arch: %q, os: %q, variant: %q)", "newer", options.Architec
ture, options.OS, options.Variant)
pullPolicy = config.PullPolicyNewer
default:
logrus.Debugf("Enforcing pull policy to %q to sup
port custom platform (arch: %q, os: %q, variant: %q)", "always", options.Archite
cture, options.OS, options.Variant)
pullPolicy = config.PullPolicyAlways
}
}
} }
if pullPolicy == config.PullPolicyNever { if pullPolicy == config.PullPolicyNever {
if localImage != nil { if localImage != nil {
logrus.Debugf("Pull policy %q but no local image has been found for %s", pullPolicy, imageName) logrus.Debugf("Pull policy %q but no local image has been found for %s", pullPolicy, imageName)
return []string{resolvedImageName}, nil return []string{resolvedImageName}, nil
} }
logrus.Debugf("Pull policy %q and %s resolved to local image %s", pullPolicy, imageName, resolvedImageName) logrus.Debugf("Pull policy %q and %s resolved to local image %s", pullPolicy, imageName, resolvedImageName)
return nil, errors.Wrap(storage.ErrImageUnknown, imageName) return nil, errors.Wrap(storage.ErrImageUnknown, imageName)
} }
skipping to change at line 415 skipping to change at line 433
if localImage != nil && strings.HasPrefix(localImage.ID(), imageName) { if localImage != nil && strings.HasPrefix(localImage.ID(), imageName) {
switch pullPolicy { switch pullPolicy {
case config.PullPolicyAlways: case config.PullPolicyAlways:
return nil, errors.Errorf("pull policy is always but imag e has been referred to by ID (%s)", imageName) return nil, errors.Errorf("pull policy is always but imag e has been referred to by ID (%s)", imageName)
default: default:
return []string{resolvedImageName}, nil return []string{resolvedImageName}, nil
} }
} }
// If we found a local image, we should use it's locally resolved name // If we found a local image, we should use it's locally resolved name
// (see containers/buildah #2904). // (see containers/buildah/issues/2904). An exception is if a custom
if localImage != nil { // platform is specified (e.g., `--arch=arm64`). In that case, we need
// to pessimistically pull the image since some images declare wrong
// platforms making platform checks absolutely unreliable (see
// containers/podman/issues/10682).
//
// In other words: multi-arch support can only be as good as the images
// in the wild.
if localImage != nil && !customPlatform {
if imageName != resolvedImageName { if imageName != resolvedImageName {
logrus.Debugf("Image %s resolved to local image %s which will be used for pulling", imageName, resolvedImageName) logrus.Debugf("Image %s resolved to local image %s which will be used for pulling", imageName, resolvedImageName)
} }
imageName = resolvedImageName imageName = resolvedImageName
} }
sys := r.systemContextCopy() sys := r.systemContextCopy()
resolved, err := shortnames.Resolve(sys, imageName) resolved, err := shortnames.Resolve(sys, imageName)
if err != nil { if err != nil {
return nil, err return nil, err
 End of changes. 6 change blocks. 
21 lines changed or deleted 54 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)