-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix sorting of json formatted list of images #6686
Conversation
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]>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: HarryMichal 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 |
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 Once the patch is verified, the new status will be reflected by the 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. |
/ok-to-test |
The JSON formatted output of
podman images
was not sorted when a sorting option was specified. This was due to the fact that sorting incmd/podman/images/list.go
relies on theimageReporter
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