Skip to content

cmd/list, pkg/podman: Eliminate getContainers() by doing everything in podman.GetContainers()#1775

Open
debarshiray wants to merge 3 commits intocontainers:mainfrom
debarshiray:wip/rishi/cmd-list-pkg-podman-getContainers
Open

cmd/list, pkg/podman: Eliminate getContainers() by doing everything in podman.GetContainers()#1775
debarshiray wants to merge 3 commits intocontainers:mainfrom
debarshiray:wip/rishi/cmd-list-pkg-podman-getContainers

Conversation

@debarshiray
Copy link
Member

@debarshiray debarshiray commented Mar 23, 2026

These are steps towards eliminating the code in getContainers() by doing everything in podman.GetContainers().

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

Before this change in commit 2369da5, it probably made some sense to keep podman.GetContainers() only as a thin wrapper to invoke podman ps with different options, and to do everything else in getContainers(). However, since then more is being done inside the podman package (eg., unmarshalling the podman ps JSON in commit d032302), and getContainers() is the only caller of podman.GetContainers().

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

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

containers#1775
@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 way arguments are passed to the podman ps command when listing containers. Instead of individual call sites constructing arguments, the podman.GetContainers wrapper function now internally defines the necessary flags, leading to a more consistent and maintainable approach for retrieving container lists.

Highlights

  • Refactoring getContainers call: The getContainers function in src/cmd/list.go was simplified by removing the explicit passing of arguments to podman.GetContainers.
  • Centralized podman ps arguments: The podman.GetContainers function in src/pkg/podman/podman.go was modified to no longer accept variadic arguments and now internally hardcodes the --all and --sort names flags for the podman ps command, centralizing argument handling.

🧠 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.

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.

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 debarshiray force-pushed the wip/rishi/cmd-list-pkg-podman-getContainers branch from 01de68a to ef0b302 Compare March 23, 2026 22:44
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 how containers are fetched by moving the podman ps arguments from cmd/list.go into pkg/podman/podman.go. This is a good simplification. My review includes a suggestion to take this refactoring a step further by also moving the container filtering logic into the podman package, which would better align with the PR's title and improve code modularity.

... not getContainers().

This is a step towards eliminating the code in getContainers() by doing
everything in podman.GetContainers().  This removes one unnecessary
layer of code.

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

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

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

containers#1775
@softwarefactory-project-zuul
Copy link

@softwarefactory-project-zuul
Copy link

@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