Skip to content

Conversation

@DaliborKr
Copy link
Collaborator

Introduces an Image interface based on the conversation in PR #1707.

Similar to how container information is handled (introduced in commits e611969 and ec7eb59), this PR abstracts the representation of an image. This is necessary because podman inspect --type image and podman images return different JSON structures. The Image interface provides a unified way to access image data, with two distinct implementations to handle the different JSON formats.

Updates related functions:

  • GetImages() now returns an Images iterator, which handles image flattening and sorting internally.
  • InspectImage() now returns an Image interface instead of a generic map[string]interface{}.
  • The IsToolboxImage() function has been replaced with an IsToolbx() method on the Image interface.

Adds unit tests: This PR includes unit tests for the new Image interface implementation, covering the output of both podman inspect --type image and podman images.

In reaction to the conversation in PR containers#1707, I made suggested changes
to the implementation in terms of how Image information, received
from Podman, is represented and treated in the Toolbx code. I used
the same procedure as in the case of representing Containers:
 - Commit e611969
 - Commit ec7eb59

In short, the JSON from 'podman inspect --type image' and
'podman images' are different, so logically, there should be
different implementations of the JSON.Unmarshaler interface [1]
for them as well. The new Image interface provides access to the
values ​​parsed from the JSONs and two different concrete types,
which are implemented separately to handle the differences in
the JSONs.

GetImages() now returns an Images iterator-like structure that
handles image flattening and sorting internally. InspectImage()
returns an Image interface instead of map[string]interface{},
and the IsToolboxImage() function was replaced with the IsToolbx()
method on the Image interface.

[1] https://pkg.go.dev/encoding/json#Unmarshaler

Signed-off-by: Dalibor Kricka <[email protected]>
Provides Go Unit tests for the Image interface implementation
introduced in commit fd715a9. Tested were results of Podman
starting on version 1.1.2, which should be sufficient since
the minimum required Podman version is 1.6.4 (see commit
8e80dd5). Covered are structures representing podman commands
'podman inspect --type image' and 'podman images'.

Signed-off-by: Dalibor Kricka <[email protected]>
@DaliborKr DaliborKr requested a review from debarshiray as a code owner October 7, 2025 15:44
@softwarefactory-project-zuul
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant