diff --git a/src/cmd/list.go b/src/cmd/list.go index 51c6f9e..8e78b82 100644 --- a/src/cmd/list.go +++ b/src/cmd/list.go @@ -52,11 +52,18 @@ var ( onlyImages bool } - // toolboxLabels holds labels used by containers/images that mark them as compatible with Toolbox - toolboxLabels = map[string]string{ + // toolboxImageLabels holds labels used by images that mark them as compatible with Toolbox + toolboxImageLabels = map[string]string{ "com.github.debarshiray.toolbox": "true", "com.github.containers.toolbox": "true", + "com.redhat.component": "ubi8-container", } + + // toolboxContainerLabels holds labels used by container that mark them as compatible with Toolbox + toolboxContainerLabels = map[string]string{ + "com.github.debarshiray.toolbox": "true", + "com.github.containrs.toolbox": "true", + } ) var listCmd = &cobra.Command{ @@ -157,7 +164,7 @@ func getContainers() ([]toolboxContainer, error) { continue } - for label := range toolboxLabels { + for label := range toolboxContainerLabels { if _, ok := c.Labels[label]; ok { isToolboxContainer = true break @@ -222,7 +229,7 @@ func getImages() ([]toolboxImage, error) { continue } - for label := range toolboxLabels { + for label := range toolboxImageLabels { if _, ok := i.Labels[label]; ok { isToolboxImage = true break diff --git a/test/system/000-setup.bats b/test/system/000-setup.bats index 019b035..67eeae0 100644 --- a/test/system/000-setup.bats +++ b/test/system/000-setup.bats @@ -7,5 +7,6 @@ load 'libs/helpers' _pull_and_cache_distro_image $(get_system_id) $(get_system_version) || die # Cache all images that will be needed during the tests _pull_and_cache_distro_image fedora 32 || die + _pull_and_cache_distro_image rhel 8.4 || die _pull_and_cache_distro_image busybox || die } diff --git a/test/system/102-list.bats b/test/system/102-list.bats index eeff007..e3f20fe 100644 --- a/test/system/102-list.bats +++ b/test/system/102-list.bats @@ -82,3 +82,31 @@ teardown() { assert_output --partial "non-default-one" assert_output --partial "non-default-two" } + +@test "list: Run 'list -i' with UBI image (8.4; public) present" { + pull_distro_image rhel 8.4 + + run toolbox list --images + + assert_success + assert_output --partial "registry.access.redhat.com/ubi8/ubi:8.4" +} + +@test "list: Run 'list' with UBI image (8.4; public), toolbox container and non-toolbox container" { + local num_of_containers + + pull_distro_image rhel 8.4 + + create_distro_container rhel 8.4 rhel-toolbox + podman create --name podman-container ubi8/ubi:8.4 /bin/sh + + num_of_containers=$(list_containers) + assert [ $num_of_containers -eq 2 ] + + run toolbox list + + assert_success + assert_line --index 1 --partial "registry.access.redhat.com/ubi8/ubi:8.4" + assert_line --index 3 --partial "rhel-toolbox" + refute_output --partial "podman-container" +} diff --git a/test/system/libs/helpers.bash b/test/system/libs/helpers.bash index 66e5dfb..dbfd5cc 100644 --- a/test/system/libs/helpers.bash +++ b/test/system/libs/helpers.bash @@ -14,7 +14,7 @@ readonly IMAGE_CACHE_DIR="${PROJECT_DIR}/image-cache" # Images declare -Ag IMAGES=([busybox]="docker.io/library/busybox" \ [fedora]="registry.fedoraproject.org/fedora-toolbox" \ - [rhel]="registry.access.redhat.com/ubi8") + [rhel]="registry.access.redhat.com/ubi8/ubi") function cleanup_all() {