Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sorting of json formatted list of images #6686

Closed

Conversation

HarryMichal
Copy link
Member

The JSON formatted output of podman images was not sorted when a sorting option was specified. This was due to the fact that sorting in cmd/podman/images/list.go relies on the imageReporter type that wasn't used in the JSON-related function.

With this getting of imageReporters is split into a separate function that is used by both Go templates and JSON parts of the listing.

The output of podman images --format json used to be pretty-printed which stopped to be the case with V2. This behaviour is returned with this PR.

Extra: I encountered a redundancy in cmd/podman/containers/ps.go where sorting of a list of containers was done twice in a row which naturally does not have an effect. The duplication is removed with this.

PS: No unit tests, yet!

Fixes #6593

cmd/podman/images/list.go heavily relies on custom type 'ImageReporter'
though it is properly used only in function 'writeTemplate'. 'writeJSON'
can also benefit from this structure because it can then use the sorting
function for 'ImageReporter' to implement sorting.

Signed-off-by: Ondřej Míchal <[email protected]>
The 'writeJSON' function did not rely on the 'imageReporter' type and
couldn't then use it's sorting function.

With this 'writeJSON' first gets imageReporters (makes use of helper
function created in previous commit[0]), applies sorting, adds extra
data and prints.

[0] Commit 44cea2c ("Split getting of image reporters") [...]

Signed-off-by: Ondřej Míchal <[email protected]>
This approach has been taken from cmd/podman/containers/ps.go

Signed-off-by: Ondřej Míchal <[email protected]>
Sorting of containers is already done in function 'getResponses'.

Signed-off-by: Ondřej Míchal <[email protected]>
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 19, 2020
@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: HarryMichal
To complete the pull request process, please assign giuseppe
You can assign the PR to them by writing /assign @giuseppe in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot
Copy link
Collaborator

Hi @HarryMichal. Thanks for your PR.

I'm waiting for a containers member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 19, 2020
@TomSweeneyRedHat
Copy link
Member

@jwhonce is this the same as your #6674?

@TomSweeneyRedHat
Copy link
Member

/ok-to-test

@openshift-ci-robot openshift-ci-robot added ok-to-test and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 19, 2020
@HarryMichal
Copy link
Member Author

I guess this can be closed in favor of #6674. For changes not related to #6593, I'll open separate PRs.

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. ok-to-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Json output of podman images not affected by sorting options
3 participants