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

can not have JSON format output of cli "podman search" or "podman image search" #8274

Closed
Edward5hen opened this issue Nov 9, 2020 · 4 comments · Fixed by #8276
Closed

can not have JSON format output of cli "podman search" or "podman image search" #8274

Edward5hen opened this issue Nov 9, 2020 · 4 comments · Fixed by #8276
Assignees
Labels
In Progress This issue is actively being worked by the assignee, please do not work on this at this time. kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@Edward5hen
Copy link
Contributor

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description
It seems we can't have the image search result in a JSON format now. I suppose it can be done by using a command like podman search --format json $IMAGE or podman image search --format json $IMAGE, but I got several lines of the string "json" instead.

Steps to reproduce the issue:

  1. podman search --format json registry.fedoraproject.org/fedora or podman image search --format json registry.fedoraproject.org/fedora

Describe the results you received:
❯ podman search --format json registry.fedoraproject.org/fedora
json
json
json
json
json
json
json
json

❯ podman image search --format json registry.fedoraproject.org/fedora
json
json
json
json
json
json
json
json

Describe the results you expected:
Display all the registries in a JSON format.

Additional information you deem important (e.g. issue happens only occasionally):
Always

Output of podman version:

❯ podman version
Version:      2.2.0-dev
API Version:  2.0.0
Go Version:   go1.14.9
Git Commit:   e2b82e6245ed9459a37dc004a2b1d593d2835cb7
Built:        Sun Nov  8 23:41:04 2020
OS/Arch:      linux/amd64

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide?

Yes

Additional environment details (AWS, VirtualBox, physical, etc.):

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Nov 9, 2020
@Edward5hen
Copy link
Contributor Author

For other random string value of argument --format, it will just print out the strings too.
❯ podman image search --format random registry.fedoraproject.org/fedora
random
random
random
random
random
random
random
random

@Luap99
Copy link
Member

Luap99 commented Nov 9, 2020

The format flag expects a go template: --format string Change the output format to a Go template

For example:

podman search --format "{{.Name}}" registry.fedoraproject.org/fedora
registry.fedoraproject.org/f29/fedora-toolbox
registry.fedoraproject.org/f30/fedora-toolbox
registry.fedoraproject.org/f31/fedora-toolbox
registry.fedoraproject.org/f32/fedora-toolbox
registry.fedoraproject.org/f33/fedora-toolbox
registry.fedoraproject.org/f34/fedora-toolbox
registry.fedoraproject.org/fedora
registry.fedoraproject.org/fedora-minimal

@Luap99
Copy link
Member

Luap99 commented Nov 9, 2020

I will open a PR to add json support.

@Luap99 Luap99 self-assigned this Nov 9, 2020
@Luap99 Luap99 added the In Progress This issue is actively being worked by the assignee, please do not work on this at this time. label Nov 9, 2020
Luap99 pushed a commit to Luap99/libpod that referenced this issue Nov 9, 2020
@jwhonce
Copy link
Member

jwhonce commented Nov 9, 2020

For other random string value of argument --format, it will just print out the strings too.
❯ podman image search --format random registry.fedoraproject.org/fedora
random
random
random
random
random
random
random
random

@Edward5hen That is expected behavior. The value of --format is fed to the Go template library.

@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 22, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
In Progress This issue is actively being worked by the assignee, please do not work on this at this time. kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants