When asked to add all of the entries from one index to another, don't
forget to carry over the artifactType.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
When saving artifacts to OCI layout directories to use as supplemental
refernces, use a different directory for each artifact(!)
When supplementing a reference in CopySpecificImages mode, only mark a
supplemental reference as the source for a specified instance if it
actually corresponds to the instance's digest.
If an artifact manifest doesn't have any file layers, remember to
catalog the empty descriptor that we add to its layer list to keep it
from being empty, as recommended.
Extend libimage/manifests.TestReference() to ensure that we're able to
copy everything that we should be able to copy.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
In the case where AddArtifact() is given both a file name and a
configuration descriptor, pay attention to both, using the media type
from the descriptor, and setting the digest and size based on the file's
contents.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
When listing instances in an image index, show their artifact types and
the names of any files that they're tracking.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Add an AddArtifact() method which will craft an artifact manifest which
references one or more files and then add that manifest to the index.
When we need to build a reference to a list that includes our artifact
manifests, save the manifests and symlinks to their "layer" blobs along
with the contents of inlined blobs in a per-image directory, and add
references to those locations to the list of images we can search for
manifests and blobs.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Use assert.NoError/assert.Error instead of assert.Nil/assert.NotNil when
the variable being checked is an `error` result.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
manifest push API must implement and leverage `retry` logic similar to
`image push` with similar defaults.
Closes: https://github.com/containers/common/issues/1664
Signed-off-by: Aditya R <arajan@redhat.com>
`c/image` recently added support for EnsureCompressionVariantsExist,
following PR exposes the feature to `c/common` manifests so actual users
can use it.
Signed-off-by: Aditya R <arajan@redhat.com>
Used `go fmt` rules to migrate away from deprecated functions, for
instance `gofmt -w -s -r 'ioutil.TempDir(a, b) -> os.MkdirTemp(a, b)'`
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
TODO() may mistakenly indicate there's something we need to change in
the future which is not the case.
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
Add a LockerForImage() function that allocates and returns a file-based
lock for an image record that we're using to hold a manifest list.
Without some locking mechanism, two processes that wish to update a list
at roughly the same time can't do so without risk of accidentally
discarding one or the other set of changes.
Multiple processes that merely want to read the list can already safely
do so; only cases with multiple writers that need to bother with using
this function.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
The new `libimage` package is an attempt to consolidate the code for
managing container images and performing operations on them such as
pulling, pushing, saving, searching, local lookups, removing etc.
Over time, Buildah, CRI-O and Podman diverged with respect to managing
container images resulting in a high amount of code duplication
rendering the tools harder to maintain (e.g., bug fixes) and harder to
extend (e.g., adding new features) than necessary.
The desire to share all that code in a common library grew and this is
an attempt to address the it.
The changes as they are now pass Buildah CI [1]. Once merged into
Buildah, I expect follow up changes when migrating Podman over to
`libimage`.
Miscellaneous changes:
* Copy `podman/pkg/signal` to `pkg/signal`.
* Copy `buildah/manifests` to `image/manifests`. Note that the unit
tests require root privileges. Skip()'s are added when running
rootless. Currently excluded from linting.
* Copy `buildah/pkg/manifests` to `pkg/manifests`. Currently excluded
from linting.
* Copy `buildah/pkg/supplemented` to `pkg/supplemented`. Currently
excluded from linting.
[1] github.com/containers/buildah/pull/3148
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>