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

"podman info" with Go template should be able to print without the appended newline #14888

Closed
eriksjolund opened this issue Jul 11, 2022 · 4 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@eriksjolund
Copy link
Contributor

eriksjolund commented Jul 11, 2022

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

/kind feature

Description

podman info with a Go template should support writing output without the extra appended newline.

(Changing this behaviour would be a breaking change so maybe a new command-line option is needed)

The extra newline makes it difficult to print an array with the entries separated by newlines without ending up with an empty line in the end. See for instance
#14887 (comment)

Steps to reproduce the issue:

  1. Run podman info -f {{.Version.Version}} | od -c

Describe the results you received:

$ podman info -f {{.Version.Version}} | od -c
0000000   4   .   1   .   1  \n
0000006

Describe the results you expected:

$ podman info -f {{.Version.Version}} | od -c
0000000   4   .   1   .   1
0000005

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

podman info also has an extra newline

$ podman info | tail -3
  OsArch: linux/amd64
  Version: 4.1.1

$ 

@vrothberg asked me to create this issue.

Output of podman version:

Client:       Podman Engine
Version:      4.1.1
API Version:  4.1.1
Go Version:   go1.18.3
Built:        Wed Jun 15 16:31:58 2022
OS/Arch:      linux/amd64

Output of podman info --debug:

host:
  arch: amd64
  buildahVersion: 1.26.1
  cgroupControllers:
  - cpu
  - io
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.0-2.fc36.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.0, commit: '
  cpuUtilization:
    idlePercent: 99.97
    systemPercent: 0.01
    userPercent: 0.01
  cpus: 16
  distribution:
    distribution: fedora
    variant: workstation
    version: "36"
  eventLogger: journald
  hostname: asus
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 5.18.10-200.fc36.x86_64
  linkmode: dynamic
  logDriver: journald
  memFree: 2574897152
  memTotal: 7578468352
  networkBackend: netavark
  ociRuntime:
    name: crun
    package: crun-1.4.5-1.fc36.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.4.5
      commit: c381048530aa750495cf502ddb7181f2ded5b400
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
  os: linux
  remoteSocket:
    path: /run/user/1000/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: true
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.2.0-0.2.beta.0.fc36.x86_64
    version: |-
      slirp4netns version 1.2.0-beta.0
      commit: 477db14a24ff1a3de3a705e51ca2c4c1fe3dda64
      libslirp: 4.6.1
      SLIRP_CONFIG_VERSION_MAX: 3
      libseccomp: 2.5.3
  swapFree: 7578054656
  swapTotal: 7578054656
  uptime: 13h 10m 53.66s (Approximately 0.54 days)
plugins:
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  volume:
  - local
registries:
  search:
  - registry.fedoraproject.org
  - registry.access.redhat.com
  - docker.io
  - quay.io
store:
  configFile: /home/esjolund/.config/containers/storage.conf
  containerStore:
    number: 11
    paused: 0
    running: 0
    stopped: 11
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/esjolund/.local/share/containers/storage
  graphRootAllocated: 407822663680
  graphRootUsed: 345093742592
  graphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 55
  runRoot: /run/user/1000/containers
  volumePath: /home/esjolund/.local/share/containers/storage/volumes
version:
  APIVersion: 4.1.1
  Built: 1655303518
  BuiltTime: Wed Jun 15 16:31:58 2022
  GitCommit: ""
  GoVersion: go1.18.3
  Os: linux
  OsArch: linux/amd64
  Version: 4.1.1

Package info (e.g. output of rpm -q podman or apt list podman):

podman-4.1.1-1.fc36.x86_64
@openshift-ci openshift-ci bot added the kind/feature Categorizes issue or PR as related to a new feature. label Jul 11, 2022
@Luap99
Copy link
Member

Luap99 commented Jul 11, 2022

I think adding a new line is the correct thing to do with custom templates. I undersatnd that there might be use cases wehre you want to turn it off but I am not sure how such UI should look like. This would effect all go template format options.

I think in your example you should be able to do but this seems to be broken because of #13446

podman info -f '{{join .Registries "\n"}}'

The extra newline for the default output is definitely wrong

@eriksjolund
Copy link
Contributor Author

I'm new to Go templates. If it's possible print an array as separated lines just by {{join .Registries "\n"}} it looks easy enough. My use case for this issue is then no longer relevant.

@Luap99
Copy link
Member

Luap99 commented Jul 11, 2022

I just realized that .Registries is not an array/slice but rather a map so you still need a range loop.

The request is valid but we would need to figure out a good UI which should not require a new cli option IMO.

@rhatdan
Copy link
Member

rhatdan commented Jul 28, 2022

Since this has never been solved in Docker, I don't think we can easily solve it here. There is a long discussion on this in the following issue.

moby/moby#8853

This issue has some ways that you can script around it as well.

@rhatdan rhatdan closed this as completed Jul 28, 2022
@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 20, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

No branches or pull requests

3 participants