Move all code related handling container image over to the new
`libimage` package in containers/common. The new package is an
attempt to consolidate the code across the containers tools under the
github.com/containers umbrella.
The new `libimage` packages provides functionality to perform all kinds
of operations for managing images such as local lookups, pushing,
pulling, listing, removing, etc.
The following packages have been moved over the containers/common:
`manifests` -> `common/image/manifests`
`pkg/manifests` -> `common/pkg/manifests`
`pkg/supplemented` -> `common/pkg/supplemented`
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Golangs os.* functions return the name of the file/directory they
fail to use. We should not wrap these errors with the file/directory
to use names, causes stuttering when the user sees the errors, and looks
bad having huge error messages.
Since this is just code cleanup, existing tests should handle the
changes.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Wait for the goroutine that's saving a decompressed copy of the blob to
finish before checking the digest that it's computing, to avoid a race
condition which would cause us to read the digest value before we're
finished computing it.
Refuse to get involved when compression isn't gzip, pending a bigger
update to handle zstd correctly.
Set CompressionOperation and MediaType when suggesting substitutions.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Avoid calling NewImage() on the source reference when the ImageSource
that we already have returns nil from its LayerInfosForCopy() method.
For our container-as-image references, that causes a re-extraction of
uncached blobs, recomputing their digests, rebuilding the config blobs
and manifests.
The image library's copy.Image() function then asks the source reference
that we're wrapping for blobs that we listed in the rebuilt manifest,
and if any of those values differ, we fail to read them.
This would have only affected builds that specified a blob cache.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Update the blobcache implementation to match API changes to the image
library.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Closes: #1902
Approved by: rhatdan
This commit enabled to golint linter in golangci-lint and applies all
necessary fixes.
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
Closes: #1740
Approved by: rhatdan
This does not change a single line of the two functions, committed
separately to make reviews of actual changes easier.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Closes: #1218
Approved by: rhatdan
It has no users, and removing it removes an unused code branch in the putBlob
implementation.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Closes: #1218
Approved by: rhatdan
NOTE: This is a very minimal update; blobinfocache.go should be
substantially reworked to benefit from the cache instead of decompressing
layers to get the DiffID values.
Also removes some HasBlob checks in the blobinfocache test suite which don't have
a direct equivalent in the new API, and makes the test suite independent
of host's signature policy.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Closes: #1218
Approved by: rhatdan
Add a blob cache reference type which wraps other reference types. When
used to create source and destination images, it returns wrappers for
source and destination images created by the wrapped references.
The cache reference must be created with a specified directory.
Blobs that are written to a cache image destination are stored as-is on
disk. When reading a blob from a cache image source, if a blob with the
matching digest (and if specified, a matching size) can be found on
disk, read it directly instead of reading it from the real image source.
If compression or decompression is requested, the cache may return a
related blob instead of an exactly-matching blob.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Closes: #1149
Approved by: rhatdan