Merge pull request #11499 from flouthoc/inspect-tmpl-flush-writer

inspect: printTmpl must Flush writer
This commit is contained in:
OpenShift Merge Robot 2021-09-09 09:08:17 -04:00 committed by GitHub
commit 7ee5b29b07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 2 deletions

View file

@ -254,7 +254,9 @@ func printTmpl(typ, row string, data []interface{}) error {
if err != nil {
return err
}
return t.Execute(w, data)
err = t.Execute(w, data)
w.Flush()
return err
}
func (i *inspector) inspectAll(ctx context.Context, namesOrIDs []string) ([]interface{}, []error, error) {

View file

@ -80,5 +80,7 @@ func inspect(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
return t.Execute(w, *responses)
err = t.Execute(w, *responses)
w.Flush()
return err
}

View file

@ -0,0 +1,3 @@
FROM alpine
ENV TEST=" t"

View file

@ -50,6 +50,24 @@ var _ = Describe("Podman inspect", func() {
Expect(session).To(ExitWithError())
})
It("podman inspect filter should work if result contains tab", func() {
session := podmanTest.Podman([]string{"build", "--tag", "envwithtab", "build/envwithtab"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
// Verify that OS and Arch are being set
inspect := podmanTest.Podman([]string{"inspect", "-f", "{{ .Config.Env }}", "envwithtab"})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0))
// output should not be empty
// test validates fix for https://github.com/containers/podman/issues/8785
Expect(strings.Contains(inspect.OutputToString(), "TEST"))
session = podmanTest.Podman([]string{"rmi", "envwithtab"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
})
It("podman inspect with GO format", func() {
session := podmanTest.Podman([]string{"inspect", "--format", "{{.ID}}", ALPINE})
session.WaitWithDefaultTimeout()