cmd/list: Simplify code

Fallout from 2369da5d31

https://github.com/containers/toolbox/pull/1189
This commit is contained in:
Debarshi Ray 2022-12-05 23:41:00 +01:00
parent 71f73a4b31
commit 67e210378e

View file

@ -142,7 +142,6 @@ func getContainers() ([]toolboxContainer, error) {
for _, container := range containers {
var c toolboxContainer
var isToolboxContainer bool
containerJSON, err := json.Marshal(container)
if err != nil {
@ -158,14 +157,10 @@ func getContainers() ([]toolboxContainer, error) {
for label := range toolboxLabels {
if _, ok := c.Labels[label]; ok {
isToolboxContainer = true
toolboxContainers = append(toolboxContainers, c)
break
}
}
if isToolboxContainer {
toolboxContainers = append(toolboxContainers, c)
}
}
return toolboxContainers, nil
@ -205,7 +200,6 @@ func getImages() ([]toolboxImage, error) {
for _, image := range images {
var i toolboxImage
var isToolboxImage bool
imageJSON, err := json.Marshal(image)
if err != nil {
@ -221,14 +215,10 @@ func getImages() ([]toolboxImage, error) {
for label := range toolboxLabels {
if _, ok := i.Labels[label]; ok {
isToolboxImage = true
toolboxImages = append(toolboxImages, i)
break
}
}
if isToolboxImage {
toolboxImages = append(toolboxImages, i)
}
}
return toolboxImages, nil