Closed EvanCarroll closed 6 months ago
I would expect everything to use the stringification provided by map, and consistently. And not to change the implementation of stringify depending on the type of data that the template returned.
This is not a bug and works as expected. We have no control over the output from the go std lib and how it renders structs vs maps, etc... Asking for better docs is fine (https://github.com/containers/podman/issues/17676) but we cannot change the output.
Issue Description
I don't believe the documentation on
--format
is clear enough, nor do I think it can be made clear enough to accommodate for the complexity of Go's templates.Steps to reproduce the issue
Steps to reproduce the issue
podman run -d -p 1234:1234 --name evanrox alpine:3 sleep 360
podman inspect evanrox
podman inspect evanrox --format '{{ .NetworkSettings.Ports }}'
podman inspect evanrox --format '{{index .NetworkSettings.Ports "1234/tcp" 0 }}'
Describe the results you received
Using the above steps, in
The workflow people will use when they're using
podman inspect
orjq
is to iteratively refine the query until they get to the data they want. Go makes this very complex because if you get a map, you'll know how to further refine. But if you get a struct, you're stuck with{value1, value2}
and it's not clear how to refine. This is what happened here, which I later found out was because of this.The only solution I can think to this, is a very strong and bold suggestion that if using Go's
--format
and--filter
, you should always use make your first step in trouble-shooting to usejson
, ie.,If
Doesn't make it clear to you what's wrong, you should immediately grab,
Putting it another way DO NOT TROUBLESHOOT WITH THE DEFAULT OR CUSTOM STRING IMPLEMENTATIONS USING FILTER, TROUBLESHOOT WITH
json
's STRING IMPLEMENTATIONDescribe the results you expected
I would expect everything to use the stringification provided by map, and consistently. And not to change the implementation of stringify depending on the type of data that the template returned.
podman info output