-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Calling inspect
with a {{json .}}
template doesn't unwrap the object
#16436
Calling inspect
with a {{json .}}
template doesn't unwrap the object
#16436
Comments
Basically, |
Yes currently |
When a user request --format `{{json .}}` they would want the go template parser to handle it. Currently we overwrite this and assume that `{{json .}}` equals `json`. This is not correct. When the output is a range (array), i.e. podman ps, it should return one json object per line and not a json array which is the case with `json`. This is required for docker compat. Fixes containers/podman#16436 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
`--format json` should not be the same as `--format {{json .}}`, the later should actually run through the go template and thus create one json object per entry instead of an json array. Includes a vendor of c/common@main since it requires a fix from there as well. This matches docker compat. Fixes containers#16436 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Should I open a new issue or add to this? The fix may have addressed the reported issue. But taking it a step further the podman-inspect man pages clearly have a few examples where using a JSON path type of a query allows limiting the out to what you really need.
I am then trying to target the name field.
Running a similar command on a non podman host
Docker is not returning the output as an array of a single object with a document in that first element. Just a JSON doc, nothing more. Targeting the "Name" works as expectred.
|
Yes new issue. |
The '{{ json . }}' syntax has returned a single JSON document with an array of entries for images historically with podman. Since podman 4.4.0 this now returns a concatenation of JSON documents, one document per image. Our code is not able to parse a concatenation of documents. This was done to fix docker compatibility[1], because {{ json .}} was supposed to be equivalent to {{ . | json }} while podman mistakenly made it equivalent to {{ json }} IOW, we were already broken in terms of docker compat too. Since we want the single document, we need to use plain 'json' or '{{ json }}'. This picks the former since it does not appear we have a need to use any advanced features of the Go template syntax. [1] containers/podman#16436 Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
Steps to reproduce the issue:
podman inspect -f '{{json .}}' busybox
Describe the results you received:
A JSON array with a single object inside of it:
Describe the results you expected:
I'd expect the output to be the same as docker's (not sure about the formatting, but the object should be unwrapped):
docker inspect -f '{{json .}}' busybox
produces
Additional information you deem important (e.g. issue happens only occasionally):
Output of
podman version
:Output of
podman info
:Package info (
pacman -Q podman
):Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)
Yes
The text was updated successfully, but these errors were encountered: