Commit Graph

16 Commits

Author SHA1 Message Date
Nalin Dahyabhai 66b682ea98 libimage/manifests.list.Add(): preserve artifactType when all=true
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>
2024-05-28 11:03:09 -04:00
Nalin Dahyabhai 8212aa58fd Handle multiple artifacts correctly
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>
2024-02-06 19:27:47 -05:00
Nalin Dahyabhai ce57633713 libimage/manifests.list.AddArtifact(): handle descriptor+file
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>
2024-02-05 13:48:39 -05:00
Nalin Dahyabhai 848a528aa0 libimage.ManifestList.Inspect(): show artifact types and file lists
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>
2024-02-05 09:49:17 -05:00
Nalin Dahyabhai e436fdc91a libimage/manifests.list: hold artifact manifests
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>
2024-02-05 09:49:16 -05:00
Nalin Dahyabhai 7ece54ca8b libimage/manifests: manage artifact information, too
Track information about artifacts for which we're managing the artifact
manifests.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-02-05 09:36:48 -05:00
Nalin Dahyabhai 185e3fb0d3 libimage/manifests/manifests_test.go: use assert.NoError
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>
2024-01-23 14:39:35 -05:00
Oleksandr Redko a1db72dfa0 Simplify tests by testing.TempDir instead of os.MkdirTemp
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-05 22:54:51 +02:00
Aditya R 72c6636175 libimage: add retry options for manifest push
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>
2023-09-28 22:26:38 +05:30
Aditya R 8282fed5ba manifests_test: fix tests for compression formats
Signed-off-by: Aditya R <arajan@redhat.com>
2023-09-28 12:03:48 +05:30
Aditya R 054a131950 manifest: add support ForceCompressionFormat
Implement https://github.com/containers/image/pull/2068 for
libimage/manifest.Push

Signed-off-by: Aditya R <arajan@redhat.com>
2023-08-11 14:27:43 +05:30
Aditya R a760be0b55 manifests,push: add support for AddCompression
`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>
2023-07-27 13:51:10 +05:30
Valentin Rothberg e17483b871 bump to golangci-lint v1.50.0
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>
2022-10-17 15:03:07 +02:00
Valentin Rothberg 0d2296e61e libimage/manifests: tests: use ctx.Background()
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>
2022-05-25 10:49:45 +02:00
Nalin Dahyabhai 054c4db996 Add libimage/manifests.LockerForImage()
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>
2021-07-23 13:12:17 -04:00
Valentin Rothberg 32a28aee73 new libimage package
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>
2021-04-21 11:17:47 +02:00