mirror of
https://github.com/containers/podman.git
synced 2025-12-01 10:38:05 +08:00
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:
26
vendor/github.com/containers/buildah/pkg/blobcache/blobcache.go
generated
vendored
26
vendor/github.com/containers/buildah/pkg/blobcache/blobcache.go
generated
vendored
@@ -10,6 +10,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/containers/buildah/docker"
|
||||
"github.com/containers/common/libimage"
|
||||
"github.com/containers/image/v5/docker/reference"
|
||||
"github.com/containers/image/v5/image"
|
||||
"github.com/containers/image/v5/manifest"
|
||||
@@ -82,6 +83,21 @@ func makeFilename(blobSum digest.Digest, isConfig bool) string {
|
||||
return blobSum.String()
|
||||
}
|
||||
|
||||
// CacheLookupReferenceFunc wraps a BlobCache into a
|
||||
// libimage.LookupReferenceFunc to allow for using a BlobCache during
|
||||
// image-copy operations.
|
||||
func CacheLookupReferenceFunc(directory string, compress types.LayerCompression) libimage.LookupReferenceFunc {
|
||||
// NOTE: this prevents us from moving BlobCache around and generalizes
|
||||
// the libimage API.
|
||||
return func(ref types.ImageReference) (types.ImageReference, error) {
|
||||
ref, err := NewBlobCache(ref, directory, compress)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error using blobcache %q", directory)
|
||||
}
|
||||
return ref, nil
|
||||
}
|
||||
}
|
||||
|
||||
// NewBlobCache creates a new blob cache that wraps an image reference. Any blobs which are
|
||||
// written to the destination image created from the resulting reference will also be stored
|
||||
// as-is to the specified directory or a temporary directory. The cache directory's contents
|
||||
@@ -141,7 +157,7 @@ func (r *blobCacheReference) HasBlob(blobinfo types.BlobInfo) (bool, int64, erro
|
||||
return true, fileInfo.Size(), nil
|
||||
}
|
||||
if !os.IsNotExist(err) {
|
||||
return false, -1, errors.Wrapf(err, "error checking size of %q", filename)
|
||||
return false, -1, errors.Wrap(err, "checking size")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +171,7 @@ func (r *blobCacheReference) Directory() string {
|
||||
func (r *blobCacheReference) ClearCache() error {
|
||||
f, err := os.Open(r.directory)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error opening directory %q", r.directory)
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
defer f.Close()
|
||||
names, err := f.Readdirnames(-1)
|
||||
@@ -165,7 +181,7 @@ func (r *blobCacheReference) ClearCache() error {
|
||||
for _, name := range names {
|
||||
pathname := filepath.Join(r.directory, name)
|
||||
if err = os.RemoveAll(pathname); err != nil {
|
||||
return errors.Wrapf(err, "error removing %q while clearing cache for %q", pathname, transports.ImageName(r))
|
||||
return errors.Wrapf(err, "clearing cache for %q", transports.ImageName(r))
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -216,7 +232,7 @@ func (s *blobCacheSource) GetManifest(ctx context.Context, instanceDigest *diges
|
||||
}
|
||||
if !os.IsNotExist(err) {
|
||||
s.cacheErrors++
|
||||
return nil, "", errors.Wrapf(err, "error checking for manifest file %q", filename)
|
||||
return nil, "", errors.Wrap(err, "checking for manifest file")
|
||||
}
|
||||
}
|
||||
s.cacheMisses++
|
||||
@@ -246,7 +262,7 @@ func (s *blobCacheSource) GetBlob(ctx context.Context, blobinfo types.BlobInfo,
|
||||
s.mu.Lock()
|
||||
s.cacheErrors++
|
||||
s.mu.Unlock()
|
||||
return nil, -1, errors.Wrapf(err, "error checking for cache file %q", filepath.Join(s.reference.directory, filename))
|
||||
return nil, -1, errors.Wrap(err, "checking for cache")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user