-
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
\t
in --format does not preserve tab character
#10974
Comments
@jwhonce PTAL |
@asottile We utilize the go text/tabwriter which is converting your given tab to a column separator and padding the cells with spaces. The go given solution is: podman history $'--format={{.ID}}\xff\t\xff{{.Created}}' someimage
|
@jwhonce my problem is the output is different than docker so I can't currently get a working solution that works in both |
@jwhonce If we were to change to match Docker, would that be a breaking change - is anyone relying on tab as a separator? |
@mheon Correct, we are using text/tabwriter's for the formatted output in all of our commands. |
@asottile Is something like |
that produces the same output between podman and docker but I don't see how it's relevant as it does not include a tab character |
@jwhonce, any chance we could turn the single strings with tabs into string slices? That would allow different packages for rendering (e.g, https://github.com/olekukonko/tablewriter). I wrote a similar package a couple of years ago when porting vgrep to Go: https://github.com/olekukonko/tablewriter |
A friendly reminder that this issue had no activity for 30 days. |
A friendly reminder that this issue had no activity for 30 days. |
@vrothberg @jwhonce Any ideas on this one? |
Let's wait for a head nod from @jwhonce since he has a deep understanding of the formatting code. |
A friendly reminder that this issue had no activity for 30 days. |
@vrothberg @rhatdan Dug through the text/tabwriter library, docker and podman formatting code to determine the root reason for the difference. Summary: Both leverage Go's text/template library. Podman always uses a text/tabwriter when rendering the output for commands using the common/report pkg. Docker only uses text/tabwriter when the "table" keyword is given in the --format value. I have an idea I'm going to research. Another potential issue I have found in this research is Docker uses different values for their tabwriter instances per command. We currently use the same values for all commands. This could cause padding to be different when the output is rendered. The common/report library does support unique values. |
* Add additional replacer for ('\', 'n') -> "\n" * New type Formatter embeds Template and writer/tabwriter handling * tabwriter.Init() is exposed to allow updating the tabwriter settings Note: If template origin is OriginPodman or has "table" keyword prefix output will be filtered through tabwriter. Otherwise, output will be rendered using given writer. Note: Once all podman commands have been updated a follow on PR will remove the old report.Template and report.Writer code. See containers/podman#10974 Signed-off-by: Jhon Honce <[email protected]>
* Add additional replacer for ('\', 'n') -> "\n" * New type Formatter embeds Template and writer/tabwriter handling * tabwriter.Init() is exposed to allow updating the tabwriter settings Note: If template origin is OriginPodman or has "table" keyword prefix output will be filtered through tabwriter. Otherwise, output will be rendered using given writer. Note: Once all podman commands have been updated a follow on PR will remove the old report.Template and report.Writer code. See containers/podman#10974 Signed-off-by: Jhon Honce <[email protected]>
Leverage new report.Formatter allowing better compatibility from podman command output. See containers#10974 See containers#12455 Depends on containers/common#831 Signed-off-by: Jhon Honce <[email protected]>
Leverage new report.Formatter allowing better compatibility from podman command output. Follow on PR's will cover containers, etc. See containers#10974 Signed-off-by: Jhon Honce <[email protected]>
[NO NEW TESTS NEEDED] Support better compatibility output for podman system commands * Format and content of output from podman version changed to be more compatible See containers#10974 Depends on containers/common#831 Signed-off-by: Jhon Honce <[email protected]>
[NO NEW TESTS NEEDED] Support better compatibility output for podman pods commands See containers#10974 Depends on containers/common#831 Signed-off-by: Jhon Honce <[email protected]>
A friendly reminder that this issue had no activity for 30 days. |
I believe this is now fixed. Reopen if I am mistaken. |
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
When using
\t
in a--format
(such as withpodman history
) I expect to receive tab characters in the output -- but it appears that podman is expanding them to spaces. docker preserves these characters in the output.Steps to reproduce the issue:
podman history $'--format={{.ID}}\t{{.CreatedBy}} someimage
(it may be useful to pipe this to
hd -c
)Describe the results you received:
I do not see any tab characters in the output
Describe the results you expected:
I expect tab characters to separate the ID and the command
Additional information you deem important (e.g. issue happens only occasionally):
Output of
podman version
:Output of
podman info --debug
:Package info (e.g. output of
rpm -q podman
orapt list podman
):Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/master/troubleshooting.md)
Yes
Additional environment details (AWS, VirtualBox, physical, etc.):
I'm running virtualbox, but I don't think it affects this
The text was updated successfully, but these errors were encountered: