Skip to content

Commit

Permalink
Hide container/image Command details for quadlets
Browse files Browse the repository at this point in the history
Quadlets have an `EntryPoint` and no `Command` so for quadlets we would
have shown an empty `Command` which isn't terribly useful or
informative.
  • Loading branch information
jelly committed Jan 14, 2025
1 parent 87f0d10 commit 3d5c52e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/ContainerDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ const ContainerDetails = ({ container }) => {
<DescriptionListTerm>{_("Image")}</DescriptionListTerm>
<DescriptionListDescription>{container.ImageName}</DescriptionListDescription>
</DescriptionListGroup>
{container.Config?.Cmd &&
<DescriptionListGroup>
<DescriptionListTerm>{_("Command")}</DescriptionListTerm>
<DescriptionListDescription>{utils.quote_cmdline(container.Config?.Cmd)}</DescriptionListDescription>
<DescriptionListDescription>{utils.quote_cmdline(container.Config.Cmd)}</DescriptionListDescription>
</DescriptionListGroup>
}
</DescriptionList>
</FlexItem>
<FlexItem>
Expand Down
2 changes: 1 addition & 1 deletion src/ImageDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const _ = cockpit.gettext;
const ImageDetails = ({ containers, image, showAll }) => {
return (
<DescriptionList className='image-details' isAutoFit>
{image.Command !== "" &&
{image.Command &&
<DescriptionListGroup>
<DescriptionListTerm>{_("Command")}</DescriptionListTerm>
<DescriptionListDescription>{utils.quote_cmdline(image.Command)}</DescriptionListDescription>
Expand Down
31 changes: 31 additions & 0 deletions test/check-application
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,37 @@ class TestApplication(testlib.MachineCase):
b.wait_not_in_text("#containers-images", "<none>:<none>")
b.wait_not_in_text("#containers-containers", IMG_INTERMEDIATE)

# Image without a Command, shows no Command. This is common for podman quadlets
IMG_ENTRYPOINT = "localhost/test-entrypoint"
tmpdir = self.execute(auth, "mktemp -d").strip()
self.addCleanup(self.execute, auth, f"rm -r {tmpdir}")
self.execute(auth, f"echo 'FROM {IMG_REGISTRY}\nENTRYPOINT /entrypoint' > {tmpdir}/Dockerfile")
self.execute(auth, f"podman build -t {IMG_ENTRYPOINT} {tmpdir}")

b.click(f"#containers-images tr:contains('{IMG_ENTRYPOINT}') td.pf-v5-c-table__toggle button")
b.wait_in_text("#containers-images tbody.pf-m-expanded tr .image-details", "/bin/sh -c /entrypoint")
b.wait_not_in_text("#containers-images tbody.pf-m-expanded tr .image-details", "Command")

b.click(f'#containers-images tbody tr:contains("{IMG_ENTRYPOINT}") .ct-container-create')
b.wait_visible('div.pf-v5-c-modal-box header:contains("Create container")')
b.set_input_text("#run-image-dialog-name", "no-cmd")
b.wait_visible("#run-image-dialog-command[value='']")
b.wait_text("#run-image-dialog-entrypoint", "/bin/sh -c /entrypoint")

b.click('.pf-v5-c-modal-box__footer #create-image-create-run-btn')
b.wait_not_present("div.pf-v5-c-modal-box")
self.waitContainerRow("no-cmd")
self.toggleExpandedContainer("no-cmd")
b.wait_in_text("#containers-containers tbody tr:contains('no-cmd')", IMG_ENTRYPOINT)
b.wait_not_in_text("#containers-containers tbody tr:contains('no-cmd')", "Command")

sha = self.execute(auth, f"podman inspect --format '{{{{.Id}}}}' {IMG_ENTRYPOINT}").strip()
entrypoint_sel = f"#containers-images tbody tr[data-row-id=\"{sha}{auth}\"]".lower()
clickDeleteImage(entrypoint_sel)
self.confirm_modal("Delete")
self.confirm_modal("Force delete")
b.wait_not_in_text("#containers-images", "<none>:<none>")

def testCommitUser(self):
self._testCommit(False)

Expand Down

0 comments on commit 3d5c52e

Please sign in to comment.