Skip to content

Commit

Permalink
lcitool: fix compat with podman 4.4.0 and docker
Browse files Browse the repository at this point in the history
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é <[email protected]>
  • Loading branch information
berrange committed Feb 23, 2023
1 parent 6e3c5cc commit 9a78b3f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lcitool/containers/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@ def _images(self):
:returns: a string in JSON format containing image details.
"""

# podman images --format {{json .}} --filter dangling=false
# podman images --format json --filter dangling=false

cmd_args = ["--format", "{{json .}}", "--filter", "dangling=false"]
cmd_args = ["--format", "json", "--filter", "dangling=false"]
cmd = [self.engine, "images"]

cmd.extend(cmd_args)
Expand Down

0 comments on commit 9a78b3f

Please sign in to comment.