Commit Graph

3 Commits

Author SHA1 Message Date
Valentin Rothberg fa2e6ee0bf libimage: normalize platforms correctly
Use containerd's platform package for platform checks. While the OCI
image spec requires the platform values to conform with GOOS and GOARCH
definitions of Go' runtime package, the values of uname are used by
convention.  Supporting these values silences annoying false-positive
warnings.

Fixes: #containers/podman/issues/14669
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-06-28 13:44:02 +02:00
Valentin Rothberg ba6a154f23 libimage: tweak platform checks
Do not check the platform of an image when it was looked up by it's ID.
In that case we must assume that the user/tool knows what they are
doing.

Further make the warnings configurable via a new `PlatformPolicy` field
in the `ImageLookupOptions`.  By default, the error will only be printed
on the debug logs.  User can opt-in to display the error on the warning
level.  Not all code paths should warn.  For instance, when inspecting
an image.  This way, consumers of libimage can opt-in.  The policy can
later on be extended to error out instead of logging.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-06-08 11:18:47 +02:00
Valentin Rothberg a06ba9fc05 libimage: image lookup: check platform
Check the platform when looking up images locally.  When the user
requested a custom platform and a local image doesn't match, the
image will be discarded.  Otherwise a warning will be emitted.

Also refactor the code to make it more maintainable in the future.

Fixes: containers/podman/issues/12682
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-05-31 16:59:11 +02:00