Commit Graph

290 Commits

Author SHA1 Message Date
Brent Baude 11ea8396fd Add ImageListSelection to copier options
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>
2024-09-19 13:42:38 -05:00
Paul Holzinger 805e7ae406 update golangci-lint to 1.60.3
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>
2024-09-03 15:57:02 +02:00
Jan Rodák 946dc49677 Improve runtime.layerTree method to be consistent
Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2024-08-28 16:00:59 +02:00
Jan Rodák bb78342714 Refactor Image filter
Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2024-08-28 15:59:32 +02:00
Jan Rodák 6b1528f145 Add ListImagesByNames and change the ListImages API
Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2024-08-28 15:19:53 +02:00
Jan Rodák e5b4d28057 Create test for ListImages methode
Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2024-08-28 11:48:28 +02:00
Jan Rodák 0a959160bb Fix SA1019: replace deprecated github.com/containerd/containerd/platforms with github.com/containerd/platforms
Signed-off-by: Jan Rodák <hony.com@seznam.cz>

Vendor containerd/platforms

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2024-08-22 09:51:42 +02:00
Matt Heon 197e4def96 Use SystemContext when creating manifest references
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>
2024-07-31 08:08:10 -04:00
Paul Holzinger 0bb0fcdefc libimage: recommend podman system check over reset
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>
2024-07-23 10:43:24 +02:00
Daniel J Walsh 1602e53b32 Display same error as split
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>
2024-07-15 16:18:07 -04:00
Nalin Dahyabhai 7aa2fce6f3 Make the definition of LookupReferenceFunc unconditional
Move the definition of our LookupReferenceFunc type alias to a file that
isn't conditionally compiled.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-07-15 10:24:02 -04:00
Paul Holzinger f3f39c4c05 replace k8s.gcr.io with registry.k8s.io
We see issues in CI where we fail to pull from k8s.gcr.io. As k8s uses a
new registry URL migrate to that[1] and hope it fixes the issues.

[1] https://kubernetes.io/blog/2023/02/06/k8s-gcr-io-freeze-announcement/

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-06-18 11:37:12 +02:00
openshift-merge-bot[bot] 902d1c7d46 Merge pull request #2045 from nalind/clear-variant
libimage.ManifestList.AnnotateInstance(): allow clearing variant values
2024-06-06 13:08:39 +00:00
Nalin Dahyabhai 3393aeef9c Remove nil checks before calling slices.Clone/maps.Clone
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>
2024-06-05 17:59:22 -04:00
Nalin Dahyabhai c13fc2cbfe libimage.ManifestList.AnnotateInstance(): allow clearing variant values
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>
2024-06-05 17:45:28 -04:00
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
Daniel J Walsh 9293f7178d Fix spelling mistake
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-05-27 06:14:44 -04:00
tomsweeneyredhat 5d8d956a5b Update a test per c/image pull 2408
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>
2024-05-22 18:33:24 -04:00
Colin Walters 3de8d66026 libimage: Add err context for normalizeTaggedDigestedString
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>
2024-04-26 08:43:35 -04:00
Paul Holzinger 7e485a635f Replace golang.org/x/exp/slices with slices from std
Use "slices" from the standard library, this package was added in go
1.21 so we can use it now.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-04-22 14:12:47 +02:00
Giuseppe Scrivano 175da180d9 libimage: use fileutils.(Le|E)xists
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-04-10 12:23:07 +02:00
openshift-merge-bot[bot] 93fa77f3c7 Merge pull request #1919 from nalind/index-resolve-images
manifest add: check for local images last
2024-04-02 18:44:48 +00:00
openshift-merge-bot[bot] c7b0f576a6 Merge pull request #1917 from nalind/index-add-annotations
manifests: preserve Annotations when adding from indexes
2024-04-02 17:08:33 +00:00
Nalin Dahyabhai c58341d561 manifest add: check for local images last
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>
2024-03-29 17:15:56 -04:00
Nalin Dahyabhai 966738be5b manifests: preserve Annotations and URLs when adding from indexes
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>
2024-03-25 09:48:52 -04:00
Nalin Dahyabhai 2f0cf99f30 Add a libimage.Runtime.LoadReference for loading images
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>
2024-03-25 09:40:54 -04:00
Paul Holzinger d240865a45 lint: update golangci-lint to v1.56.2
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>
2024-03-05 18:10:32 +01:00
Daniel J Walsh b956dbdefa Report error events on pull failures
Fixes: https://github.com/containers/podman/issues/21458

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-02-29 11:32:41 -05:00
Daniel J Walsh 6313680fd1 Fix dockerDaemonTransport vendor
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-02-26 15:27:29 -05:00
Daniel J Walsh 15ec5d8453 docker-archive/DockerV3Schema2MediaType only support Gzip compression
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>
2024-02-24 21:16:28 -05:00
Daniel J Walsh b39e81e0e2 Default Pull/Push to use containers.conf Retry, RetryDelay
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-02-22 08:13:45 -05:00
Nalin Dahyabhai 8f70d181e7 libimage.ManifestList: add AddArtifact()
* 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>
2024-02-13 12:09:28 -05: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
openshift-merge-bot[bot] 3a6b246df5 Merge pull request #1843 from nalind/artifact-config-desc
libimage/manifests.list.AddArtifact(): handle descriptor+file
2024-02-06 15:56:10 +00:00
Nalin Dahyabhai 2cf5a6f909 libimage/manifests.LoadFromImage(): don't return a stale error
After we've dealt with missing files, don't accidentally return the
missing file error.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-02-06 09:29:59 -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 91a4ee58e2 libimage/manifests.list.SaveToImage(): use ImageOptions
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>
2024-02-05 09:36:48 -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 c270f76f4c ibimage/manifests.list.Add(): don't read platform info for artifacts
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>
2024-02-05 09:36:48 -05:00
joshvanl a67e9564fb Check if node layer nil inside for loop to ensure full parent tree is traversed
Signed-off-by: joshvanl <me@joshvanl.dev>
2024-01-26 17:06:59 +00:00
joshvanl 489f249205 Fix `podman system df` panic
Fix panic when running `podman system df` where a `node.layer` is nil.

Fixes https://github.com/containers/podman/issues/20942

Signed-off-by: joshvanl <me@joshvanl.dev>
2024-01-25 21:08:54 +00: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
Urvashi Mohnani d3cfbdf2ef Fix filter logic for reference key
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>
2024-01-19 09:56:59 -05:00
Urvashi Mohnani 02cf8cceb4 Fix Image.applyFilters to do an AND logic
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>
2024-01-17 14:06:49 -05:00
openshift-merge-bot[bot] aa5ddf2159 Merge pull request #1790 from alexandear/linters-enable-contextcheck
linters: enable contextcheck
2024-01-09 15:01:53 +00:00
openshift-merge-bot[bot] 98b7332bfd Merge pull request #1789 from alexandear/refactor-map-init
Refactor map init with short declaration syntax
2024-01-08 14:42:32 +00:00
openshift-merge-bot[bot] 1ff3b1ceae Merge pull request #1787 from alexandear/test-use-t-tempdir
Simplify tests with testing.TempDir instead of os.MkdirTemp
2024-01-08 14:12:42 +00:00
Oleksandr Redko 2c6e273d55 linters: enable contextcheck
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-06 20:28:57 +02:00