Fix podman images... missing headers in table templates

Signed-off-by: Jhon Honce <jhonce@redhat.com>
This commit is contained in:
Jhon Honce
2020-11-18 09:09:53 -07:00
parent e82ec90007
commit 2a02833e9f
3 changed files with 13 additions and 6 deletions

View File

@ -126,8 +126,8 @@ func images(cmd *cobra.Command, args []string) error {
case listFlag.quiet: case listFlag.quiet:
return writeID(imgs) return writeID(imgs)
default: default:
if cmd.Flag("format").Changed { if cmd.Flags().Changed("format") && !parse.HasTable(listFlag.format) {
listFlag.noHeading = true // V1 compatibility listFlag.noHeading = true
} }
return writeTemplate(imgs) return writeTemplate(imgs)
} }

View File

@ -278,7 +278,7 @@ WORKDIR /test
It("podman images sort by values", func() { It("podman images sort by values", func() {
sortValueTest := func(value string, result int, format string) []string { sortValueTest := func(value string, result int, format string) []string {
f := fmt.Sprintf("{{.%s}}", format) f := fmt.Sprintf("{{.%s}}", format)
session := podmanTest.Podman([]string{"images", "--sort", value, "--format", f}) session := podmanTest.Podman([]string{"images", "--noheading", "--sort", value, "--format", f})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(result)) Expect(session).Should(Exit(result))

View File

@ -199,9 +199,16 @@ Labels.created_at | 20[0-9-]\\\+T[0-9:]\\\+Z
local format=$2 local format=$2
run_podman images --sort repository --format "$format" run_podman images --sort repository --format "$format"
_check_line 0 ${aaa_name} ${aaa_tag}
_check_line 1 "${PODMAN_TEST_IMAGE_REGISTRY}/${PODMAN_TEST_IMAGE_USER}/${PODMAN_TEST_IMAGE_NAME}" "${PODMAN_TEST_IMAGE_TAG}" line_no=0
_check_line 2 ${zzz_name} ${zzz_tag} if [[ $format == table* ]]; then
# skip headers from table command
line_no=1
fi
_check_line $line_no ${aaa_name} ${aaa_tag}
_check_line $((line_no+1)) "${PODMAN_TEST_IMAGE_REGISTRY}/${PODMAN_TEST_IMAGE_USER}/${PODMAN_TEST_IMAGE_NAME}" "${PODMAN_TEST_IMAGE_TAG}"
_check_line $((line_no+2)) ${zzz_name} ${zzz_tag}
} }
# Begin the test: tag $IMAGE with both the given names # Begin the test: tag $IMAGE with both the given names