Skip to content

cmd/list, pkg/podman: Eliminate getImages() by doing everything in podman.GetImages()#1772

Merged
debarshiray merged 6 commits intocontainers:mainfrom
debarshiray:wip/rishi/cmd-list-pkg-podman-getImages
Mar 19, 2026
Merged

cmd/list, pkg/podman: Eliminate getImages() by doing everything in podman.GetImages()#1772
debarshiray merged 6 commits intocontainers:mainfrom
debarshiray:wip/rishi/cmd-list-pkg-podman-getImages

Conversation

@debarshiray
Copy link
Member

@debarshiray debarshiray commented Mar 17, 2026

These are steps towards eliminating the code in getImages() by doing everything in podman.GetImages().

The getImages() function originated as listContainers(), when it invoked podman images --filter label=... through podman.GetImages() separately for each label used to identify Toolbx images, and then joined and sorted the results. This changed in commit 2369da5 when getImages() started invoking podman images only once through podman.GetImages() to get all available images, and then filtered them itself based on the labels.

Before this change in commit 2369da5, it probably made some sense to keep podman.GetImages() only as a thin wrapper to invoke podman images with different options, and to do everything else in getImages(). However, since then more is being done inside the podman package (eg., unmarshalling the podman images JSON in commit 5f324d5 and flattening the images in commit 6aab0a6), and getImages() is the only caller of podman.GetImages().

Therefore, it looks awkward to have the code to get all Toolbx images split across two functions in different packages.

#1724

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the image retrieval and processing mechanism by centralizing the logic for de-duplication and name flattening within the pkg/podman package. This change aims to simplify the cmd/list package by offloading image processing responsibilities, reducing code duplication, and improving modularity. The podman.GetImages function now handles these operations internally, making it a more comprehensive utility for fetching and preparing image data.

Highlights

  • Refactoring Image Processing: The logic for de-duplicating and flattening image names has been moved from the getImages function in src/cmd/list.go to the GetImages function in src/pkg/podman/podman.go.
  • API Change: The podman.GetImages function now accepts a fillNameWithID boolean parameter, which controls how image names are flattened.
  • Internalization of Flattening Logic: The Image.FlattenNames method has been renamed to image.flattenNames, making it an unexported (private) method within the podman package.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/cmd/list.go
    • Updated the call to podman.GetImages to pass the fillNameWithID parameter.
    • Removed the local image de-duplication logic using a processed map.
    • Removed the explicit call to image.FlattenNames as this processing is now handled by podman.GetImages.
  • src/pkg/podman/podman.go
    • Renamed the Image.FlattenNames method to image.flattenNames, making it unexported.
    • Modified the signature of GetImages to accept a new fillNameWithID boolean parameter.
    • Updated the documentation for GetImages to reflect the new fillNameWithID parameter.
    • Added internal logic within GetImages to de-duplicate images by ID and flatten their names using the new flattenNames method.
    • Note: Despite the added processing, the GetImages function currently returns the original, unflattened and unde-duplicated images slice.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request Mar 17, 2026
This is a step towards eliminating or reducing the code in getImages()
by doing everything or more in podman.GetImages().  If nothing else,
this removes the need to export Image.FlattenNames() from the podman
package.

The getImages() function originated as listContainers(), when it invoked
'podman images --filter label=...' through podman.GetImages() separately
for each label used to identify Toolbx images, and then joined and
sorted the results.  This changed in commit 2369da5 when
getImages() started invoking 'podman images' only once through
podman.GetImages() to get all available images, and then filtered them
itself based on the labels.

Before this change in commit 2369da5, it probably made some
sense to keep podman.GetImages() only as a thin wrapper to invoke
'podman images' with different options, and to do everything else in
getImages().  However, since then more is being done inside the podman
package (eg., unmarshalling the 'podman images' JSON in commit
5f324d5 and flattening the images in commit 6aab0a6),
and getImages() is the only caller of podman.GetImages().

Therefore, it looks awkward to have the code to get all Toolbx images
split across two functions in different packages.

containers#1724
containers#1772
@debarshiray debarshiray force-pushed the wip/rishi/cmd-list-pkg-podman-getImages branch from 14c376e to 616501d Compare March 17, 2026 13:33
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the image fetching logic by moving the image name flattening and de-duplication from cmd/list.go into pkg/podman/podman.go. This is a good step towards centralizing the image handling logic. However, I found a critical issue in the implementation where the refactored function returns the original unprocessed data instead of the processed results, which defeats the purpose of the change.

This is a step towards eliminating or reducing the code in getImages()
by doing everything or more in podman.GetImages().  If nothing else,
this removes the need to export Image.FlattenNames() from the podman
package.

The getImages() function originated as listContainers(), when it invoked
'podman images --filter label=...' through podman.GetImages() separately
for each label used to identify Toolbx images, and then joined and
sorted the results.  This changed in commit 2369da5 when
getImages() started invoking 'podman images' only once through
podman.GetImages() to get all available images, and then filtered them
itself based on the labels.

Before this change in commit 2369da5, it probably made some
sense to keep podman.GetImages() only as a thin wrapper to invoke
'podman images' with different options, and to do everything else in
getImages().  However, since then more is being done inside the podman
package (eg., unmarshalling the 'podman images' JSON in commit
5f324d5 and flattening the images in commit 6aab0a6),
and getImages() is the only caller of podman.GetImages().

Therefore, it looks awkward to have the code to get all Toolbx images
split across two functions in different packages.

containers#1724
containers#1772
@debarshiray debarshiray force-pushed the wip/rishi/cmd-list-pkg-podman-getImages branch from 616501d to 843208f Compare March 17, 2026 14:13
@softwarefactory-project-zuul
Copy link

Subsequent commits will use isToolbx() for image labels.  So, it can't
be in a file that's specific to containers.

containers#1724
containers#1772
This is a step towards eliminating or reducing the code in getImages()
by doing everything or more in podman.GetImages().  If nothing else,
this removes the need to keep a copy of the labels used to identify
Toolbx images for getImages().

The getImages() function originated as listContainers(), when it invoked
'podman images --filter label=...' through podman.GetImages() separately
for each label used to identify Toolbx images, and then joined and
sorted the results.  This changed in commit 2369da5 when
getImages() started invoking 'podman images' only once through
podman.GetImages() to get all available images, and then filtered them
itself based on the labels.

Before this change in commit 2369da5, it probably made some
sense to keep podman.GetImages() only as a thin wrapper to invoke
'podman images' with different options, and to do everything else in
getImages().  However, since then more is being done inside the podman
package (eg., unmarshalling the 'podman images' JSON in commit
5f324d5 and flattening the images in commit 6aab0a6),
and getImages() is the only caller of podman.GetImages().

Therefore, it looks awkward to have the code to get all Toolbx images
split across two functions in different packages.

containers#1724
containers#1772
This is a step towards eliminating the code in getImages() by doing
everything in podman.GetImages().  This removes the need to export the
podman.ImageSlice type from the podman package.

The getImages() function originated as listContainers(), when it invoked
'podman images --filter label=...' through podman.GetImages() separately
for each label used to identify Toolbx images, and then joined and
sorted the results.  This changed in commit 2369da5 when
getImages() started invoking 'podman images' only once through
podman.GetImages() to get all available images, and then filtered them
itself based on the labels.

Before this change in commit 2369da5, it probably made some
sense to keep podman.GetImages() only as a thin wrapper to invoke
'podman images' with different options, and to do everything else in
getImages().  However, since then more is being done inside the podman
package (eg., unmarshalling the 'podman images' JSON in commit
5f324d5 and flattening the images in commit 6aab0a6),
and getImages() is the only caller of podman.GetImages().

Therefore, it looks awkward to have the code to get all Toolbx images
split across two functions in different packages.

containers#1724
containers#1772
@debarshiray debarshiray changed the title cmd/list, pkg/podman: Make podman.GetImages() flatten, not getImages() cmd/list, pkg/podman: Eliminate getImages() by doing everything in podman.GetImages() Mar 17, 2026
@softwarefactory-project-zuul
Copy link

@softwarefactory-project-zuul
Copy link

@softwarefactory-project-zuul
Copy link

The getImages() function originated as listContainers(), when it invoked
'podman images --filter label=...' through podman.GetImages() separately
for each label used to identify Toolbx images.  The label was specified
using the 'args' parameter.  This changed in commit 2369da5
when getImages() started invoking 'podman images' only once through
podman.GetImages() to get all available images, with the 'args'
parameter set to a fixed value.  Then in commit 6aab0a6 the
'args' parameter became unused.

containers#1772
@softwarefactory-project-zuul
Copy link

debarshiray added a commit to debarshiray/toolbox that referenced this pull request Mar 19, 2026
@debarshiray debarshiray force-pushed the wip/rishi/cmd-list-pkg-podman-getImages branch from dd54eba to 4cd38d3 Compare March 19, 2026 13:15
@softwarefactory-project-zuul
Copy link

@debarshiray debarshiray merged commit 4cd38d3 into containers:main Mar 19, 2026
3 checks passed
@debarshiray debarshiray deleted the wip/rishi/cmd-list-pkg-podman-getImages branch March 19, 2026 14:31
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.

2 participants