migrate Podman to containers/common/libimage

Migrate the Podman code base over to `common/libimage` which replaces
`libpod/image` and a lot of glue code entirely.

Note that I tried to leave bread crumbs for changed tests.

Miscellaneous changes:

 * Some errors yield different messages which required to alter some
   tests.

 * I fixed some pre-existing issues in the code.  Others were marked as
   `//TODO`s to prevent the PR from exploding.

 * The `NamesHistory` of an image is returned as is from the storage.
   Previously, we did some filtering which I think is undesirable.
   Instead we should return the data as stored in the storage.

 * Touched handlers use the ABI interfaces where possible.

 * Local image resolution: previously Podman would match "foo" on
   "myfoo".  This behaviour has been changed and Podman will now
   only match on repository boundaries such that "foo" would match
   "my/foo" but not "myfoo".  I consider the old behaviour to be a
   bug, at the very least an exotic corner case.

 * Futhermore, "foo:none" does *not* resolve to a local image "foo"
   without tag anymore.  It's a hill I am (almost) willing to die on.

 * `image prune` prints the IDs of pruned images.  Previously, in some
   cases, the names were printed instead.  The API clearly states ID,
   so we should stick to it.

 * Compat endpoint image removal with _force_ deletes the entire not
   only the specified tag.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2021-04-22 08:01:12 +02:00
parent 8eefca5a25
commit 0f7d54b026
190 changed files with 8669 additions and 7743 deletions

View File

@ -0,0 +1,95 @@
package config
import (
"fmt"
"github.com/pkg/errors"
)
// PullPolicy determines how and which images are being pulled from a container
// registry (i.e., docker transport only).
//
// Supported string values are:
// * "always" <-> PullPolicyAlways
// * "missing" <-> PullPolicyMissing
// * "newer" <-> PullPolicyNewer
// * "never" <-> PullPolicyNever
type PullPolicy int
const (
// Always pull the image.
PullPolicyAlways PullPolicy = iota
// Pull the image only if it could not be found in the local containers
// storage.
PullPolicyMissing
// Never pull the image but use the one from the local containers
// storage.
PullPolicyNever
// Pull if the image on the registry is new than the one in the local
// containers storage. An image is considered to be newer when the
// digests are different. Comparing the time stamps is prone to
// errors.
PullPolicyNewer
// Ideally this should be the first `ioata` but backwards compatibility
// prevents us from changing the values.
PullPolicyUnsupported = -1
)
// String converts a PullPolicy into a string.
//
// Supported string values are:
// * "always" <-> PullPolicyAlways
// * "missing" <-> PullPolicyMissing
// * "newer" <-> PullPolicyNewer
// * "never" <-> PullPolicyNever
func (p PullPolicy) String() string {
switch p {
case PullPolicyAlways:
return "always"
case PullPolicyMissing:
return "missing"
case PullPolicyNewer:
return "newer"
case PullPolicyNever:
return "never"
}
return fmt.Sprintf("unrecognized policy %d", p)
}
// Validate returns if the pull policy is not supported.
func (p PullPolicy) Validate() error {
switch p {
case PullPolicyAlways, PullPolicyMissing, PullPolicyNewer, PullPolicyNever:
return nil
default:
return errors.Errorf("unsupported pull policy %d", p)
}
}
// ParsePullPolicy parses the string into a pull policy.
//
// Supported string values are:
// * "always" <-> PullPolicyAlways
// * "missing" <-> PullPolicyMissing (also "ifnotpresent" and "")
// * "newer" <-> PullPolicyNewer (also "ifnewer")
// * "never" <-> PullPolicyNever
func ParsePullPolicy(s string) (PullPolicy, error) {
switch s {
case "always":
return PullPolicyAlways, nil
case "missing", "ifnotpresent", "":
return PullPolicyMissing, nil
case "newer", "ifnewer":
return PullPolicyNewer, nil
case "never":
return PullPolicyNever, nil
default:
return PullPolicyUnsupported, errors.Errorf("unsupported pull policy %q", s)
}
}
// Deprecated: please use `ParsePullPolicy` instead.
func ValidatePullPolicy(s string) (PullPolicy, error) {
return ParsePullPolicy(s)
}