For artifact support, the copier needs to get all tags; as such, we need
to pass in the correct value for ImageListSelection.
Signed-off-by: Brent Baude <bbaude@redhat.com>
Contains fixes for new linters, removed depracted and removed linters
from the config.
Most notably because we use go 1.22 now we can get rid of the copy for
loop vars[1]. Also as of the go 1..2 we can use the new int range syntax
in for loops the new intrange linter checks that.
[1] https://go.dev/blog/loopvar-preview
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Instead of passing a nil system context when adding to a manifest
list, use a valid one, ensuring that settings like auth and TLS
verification are passed along and respected.
Fixes https://github.com/containers/podman/issues/23410
Signed-off-by: Matt Heon <mheon@redhat.com>
podman system reset nukes everything which makes not a great suggestion.
Now that we have the podman system check recommend that instead as it
actually checks the storage for corruption and might be able to repair
it.
This is important because as it turns out this warning can pop up even
in totally normal circumstances as there is a race between image and
layer listing[1]. And even if that get fixed the check command will be
the better suggestion.
[1] https://github.com/containers/podman/issues/23331
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Partial fix for https://github.com/containers/podman/issues/23120
Working on a fix for this crash, but want same error to come back as
non-remote case.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Move the definition of our LookupReferenceFunc type alias to a file that
isn't conditionally compiled.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Both slices.Clone() and maps.Clone() return `nil` when passed `nil`, so
we don't need to check for a `nil` pointer before calling them.
Imports that used the golang.org/x/exp versions of the maps and slices
packages can now use the versions in the standard library, since we
require Go 1.21.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
When AnnotateInstance() is given a non-empty Architecture value, set the
Variant value to the one that was passed in along with it, even if that
value is empty.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
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>
Update the libimage/pull_test.go file, changing quote in one line
Based on https://github.com/containers/image/pull/2408 from @mtrmac
Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
Before, here's what happens if you forget a `-v` in your bind mount for example:
```
$ podman run /dev:/dev docker.io/busybox echo hello
Error: invalid reference format
$
```
After:
```
$ podman run /dev:/dev docker.io/busybox echo hello
Error: parsing reference "/dev:/dev": invalid reference format
```
This error prefixing is common in other callers.
Signed-off-by: Colin Walters <walters@verbum.org>
When adding a reference to a manifest list or image index, if we are
guessing that it's a reference to an image in a registry, check if we
can read something from that location instead of assuming it's correct,
and if we can't, check for a local image. This will let use use local
image IDs to refer to items that we want to add to a list or index.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
When adding items from one index into another, preserve the annotations
and URLs which are set in the descriptors in the source index.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Add a LoadReference() method, for when we already know what format the
local image should be treated as, and we don't have the patience for
Load()'s guessing at it.
Teach libimage.Runtime.copyFromDefault() about the docker transport.
It's already required at build-time because it's directly referenced
elsewhere in the same file.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Adds a couple of new linters with many new warnings:
- perfsprint (fixed in code, excluded for tests)
- revive (fix the problems, disabled the dot import check as we use it
for ginkgo)
- inamedparam (disabled because it is opinionated)
- testifylint (great linter but we have like 1000+ issues that I have no
time fixing now)
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
If user does not specify a compression format and transport is
docker-archive of manifesttype is DockerV2Schema2MediaType then we need
to force Gzip compression.
This is needed when we transition to zstd or zstd:chunked by default.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
* Add a libimage.ManifestList.AddArtifact() method.
* Add IndexAnnotations and Subject to libimage.ManifestListAnnotateOptions,
for setting annotations on the index itself, and the index's subject,
respectively.
* In libimage/manifests.list.AddArtifact(), if the subject has an
artifactType in its manifest, add its value to the subject descriptor.
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>
When saving information about a list, use an ImageOptions structure to
create the whole thing at once, and only save individual data piece by
piece if we need to.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
If an instance being added to a list has a non-empty ArtifactType value
or a config.MediaType value that isn't one of the known kinds of image
configuration blobs, don't try to parse the configuration blob to figure
out the image's OS/Architecture/Variant information.
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>
For the positive case, the reference key does an OR
operation. For the negative case, the reference key
does an AND operation.
Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
When multiple filters are given, only return objects
that match all the filters given by the user.
This matches Docker behavior.
Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>