Commit Graph

249 Commits

Author SHA1 Message Date
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
Oleksandr Redko 0e202b45a1 Refactor map init with short declaration syntax
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-06 19:28:43 +02: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
Oleksandr Redko 838008f4ab Fix staticcheck issues; show all lint issues in CI
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-05 21:39:45 +02:00
openshift-merge-bot[bot] ce424557dd Merge pull request #1781 from alexandear/fix-typos-across-repo
Fix typos across repo; extend codespell config
2024-01-04 11:12:20 +00:00
Oleksandr Redko 3cc2a76ae9 Fix typos across repo; extend codespell config
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-03 23:38:47 +02:00
Oleksandr Redko ba4c7c98bb chore: remove outdated build constraints
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-03 22:56:00 +02:00
Ygal Blum a525f15fc3 Image copier: make sure ReportWriter is not nil before accessing
When running in Quiet mode, the ReportWriter can be nil causing a crash

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2023-12-04 14:34:40 +02:00
Miloslav Trmač e121cae027 Fix inspect of unsigned schema1 images
... by not incorrectly invoking the schema2 code; otherwise
it tries to unmarshal nil as JSOn, and fails.

I'm not sure whether schema1 images can contain
a comment or a health check; just not crashing is
an improvement.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-11-20 18:58:21 +01:00
Miloslav Trmač 82250038d7 Rename dockerManifest to dockerConfig
... just because this is incorrect and confusing.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-11-20 18:41:35 +01:00
Paul Holzinger 92c98a7323 libimage: add !remote tag
To prevent the podman remote client from using libimage which causes a
lot of bloat due the c/image and c/storage dependencies add the
`!remote` tag.

This will cause a hard compile time failure if the remote client ends up
pulling in libimage.

Fixes #1702

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-10-23 15:14:43 +02:00
Ygal Blum 2c59e6864f Copier: use StringWithinTransport instead of DockerReference
When trying an invalid image DockerReference maybe nil

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2023-10-22 11:04:10 +03:00
Paul Holzinger ec9d00f17b libimage: Untag should error for non existent name
podman untag should error out of a name is given which does not exists
for the given image. This regression was added in commit a4a7c28aef.

There was even a test which meant to check for it but unfortunately it
did not actually check for what it should. The doNotExist check failed
early to the upper case in the repo name.
The tests have been updated to check for actual error messages to show
ensure it is failing for the right reason.
This also showed that `normalizing name` message was included twice so
I removed one case to not stutter.

Fixes a4a7c28aef ("libimage: support parallel tag/untag")

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-10-20 12:15:45 +02:00
Paul Holzinger a4a7c28aef libimage: support parallel tag/untag
The c/storage SetNames API is depracated because it is not race free to
first get the list of names and then append our new name then write the
full list back. Instead a better Add/RemovesNames API has been added.

Tag and Untag should use these to prevent race conditions that can be
easily reproduce using podman tag in parallel. Tests have been added to
ensure it is working correctly.

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

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-10-19 14:51:14 +02:00
Valentin Rothberg 9d4b1bf156 libimage: fix computing history
Computing the history did not walk the layers correctly.  Fix that and
try to improve the code to make it easier to read and maintain for
future pairs of eyes.

A regression will also be added to the Podman PR vendoring this change.

Fixes: containers/podman/issues/20375
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-17 16:18:12 +02:00
Nalin Dahyabhai 3bcb56c0be libimage: add compat interfaces for the new platform subpackage
Add compatibility interfaces for items which have been moved from the
main libimage package to its new platform subpackage.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2023-10-12 16:17:14 -04:00
Urvashi Mohnani dce8f8791d Move platform code to its own directory
Move the platform code into its own directory
under libimage so it can be used by farm build in
podman without causing the binary size to increase a lot.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-10-12 10:38:19 -04:00
Valentin Rothberg 6923f768c2 URGENT: heal CI: fix codespell
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-03 11:15:37 +02:00
OpenShift Merge Robot 12f1c98dc5 Merge pull request #1676 from umohnani8/filters
Fix ID and Digest filters
2023-09-29 08:06:46 -04: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
Urvashi Mohnani 25bcd08753 Fix ID and Digest filters
The id and digest filters for podman images was broken
as it would only match on the full ID or Digest, so when
users would give a substring of either not results would be
given even though there were matches.
Fix to check on prefix now instead.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-09-28 12:18:08 -04:00
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
guoguangwu 97991b9967 chore: import packages only once
Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
2023-09-27 15:02:02 +08:00
Aditya R e08e68ee29 libimage/layer_tree: if parent is empty and manifest list ignore
Layer tree expectes to form a relation between child and parent
instances, however it expects an instance from manifest list which is
empty, following expectation is not possible and will always resuilt in
error.

Closes: https://github.com/containers/podman/issues/19860

[NO NEW TESTS NEEDED]
Image without layer cant be built in libimage, and `podman save`
automatically malforms such image so no such external image can be
loaded.

Signed-off-by: Aditya R <arajan@redhat.com>
2023-09-18 14:30:42 +05:30
Paul Holzinger 8bb073c089 libimage: split out search filters
This allows podman to import them on the remote client without needing
the full libimage.

Based on Miloslav's work: https://github.com/containers/podman/pull/19718

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-09-12 13:54:20 +02:00
Valentin Rothberg de32d5a9f7 linters: enable dupword
Mostly monkey work to fix comments but there was also an error message.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-09-01 11:51:25 +02:00
Valentin Rothberg ab8db10408 linters: enable whitespace
Not changing the world but useful hygiene.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-09-01 11:14:23 +02:00
Valentin Rothberg 1fa8b65281 linters: enable forbidigo
Selectively disable cases that I cannot touch or don't bother spending
time on.  Future cases will be avoided.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-09-01 11:08:17 +02:00
OpenShift Merge Robot 7ffc273928 Merge pull request #1630 from vrothberg/oci-ref
libimage: preserve optional name when pulling from OCI transport
2023-08-30 09:59:33 +02:00
Valentin Rothberg 02a72eb33e libimage: preserve optional name when pulling from OCI transport
When pulling from an OCI source, make sure to preseve the optional name.
For instance, a `podman pull oci:/tmp/foo:quay.io/foo/bar:latest` should
pull the image and name it `quay.io/foo/bar:latest`.

While at it, also fix a bug when pulling an OCI without the optional
name.  Previously, we used the path to name the image which will error
in most cases due to invalid characters (e.g., capital ones).  Hence,
apply the same trick as for the `dir` transport and generate a sha.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-08-30 09:19:42 +02:00
OpenShift Merge Robot d24aa07e87 Merge pull request #1629 from mtrmac/ManifestListData-no-deps
Move libimage.ManifestList{Descriptor,Data} to libimage/define
2023-08-29 12:40:13 +02:00
Miloslav Trmač a6d079d218 Move libimage.ManifestList{Descriptor,Data} to libimage/define
These structs are (for better or worse) a part of
Podman's API, so podman-remote needs to include the subpackage that
defines them - which is all of libimage (and c/image/v5/copy) right now.

Instead, move them to libimage/define.

Alternatively, maybe Podman's API should not directly depend on (unstable)
c/common types?!

Only moves unchanged code, should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-08-28 23:17:59 +02:00
Valentin Rothberg a60d8bd633 libimage: close all `ImageCloser`s
Make sure to close all `ImageCloser` to avoid potential memory leaks.

Fixes: containers/common#1533
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-08-28 13:57:36 +02:00
Valentin Rothberg 91b87d2bde libimage: pull: increase timeout running under systemd
Set the `EXTEND_TIMEOUT_USEC` over DBUS when pulling an image from a
registry and when running under systemd.  This will prevent a frequent
issue when running Quadlets and exceeding the default systemd start
timeout of 90 seconds when pulling the image takes too long.

Fixes: containers/podman/issues/18353
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-08-23 14:38:11 +02:00
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 fe8cc2aba2 libimage/copier: wire ForceCompressionFormat for image copy
Implement https://github.com/containers/image/pull/2068 for
libimage/copier.

Signed-off-by: Aditya R <arajan@redhat.com>
2023-08-11 14:22:27 +05:30
Aditya R 91e5c02d28 libimage/ManifestPushOptions: add AddCompression from #1585
Podman uses different API for pushing manifest list,
add `AddCompression` to ManifestPushOptions, which is implemented
here: https://github.com/containers/common/pull/1585

[NO NEW TESTS NEEDED]
Tests are added here: https://github.com/containers/common/pull/1585

Signed-off-by: Aditya R <arajan@redhat.com>
2023-08-01 12:45:18 +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
Miloslav Trmač 6c259968ca Reorganize how requiredDigest/requiredTag is determined
Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-07-13 22:12:37 +02:00
Miloslav Trmač f80096f3a2 Accept a reference.Named in referenceFuzzilyMatchingRepoAndTag
We don't need a reference.NamedTagged now.

That also makes the namedTagged variable in the caller more local.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-07-13 22:12:37 +02:00
Miloslav Trmač b5765a6100 Eliminate the isDigested variable
Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-07-13 22:12:37 +02:00
Miloslav Trmač 78ca348258 Pass the required tag, not just a bool, to referenceFuzzilyMatchingRepoAndTag
Right now that's not simpler, but it will enable simplification of the caller.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-07-13 22:12:37 +02:00