Skip to content

Commit 38e8d04

Browse files
committed
pkg/podman/podman, cmd/rmi: Change return values of IsToolboxImage()
The original version of the IsToolboxImage() function in pkg/podman/podman.go returned an error when an image was not compatible with Toolbx. The new version returns 'false' without error on a non-Toolbx container, so it can be distinguished when the image inspection actually fails. This new behavior is used in detecting such images when creating or running Toolbx containers: f06a819
1 parent f06a819 commit 38e8d04

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/cmd/rmi.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,12 @@ func rmi(cmd *cobra.Command, args []string) error {
9090
}
9191

9292
for _, image := range args {
93-
if _, err := podman.IsToolboxImage(image); err != nil {
93+
if isToolboxImage, err := podman.IsToolboxImage(image); err != nil {
9494
fmt.Fprintf(os.Stderr, "Error: %s\n", err)
9595
continue
96+
} else if !isToolboxImage {
97+
fmt.Fprintf(os.Stderr, "Error: %s is not a Toolbx image\n", image)
98+
continue
9699
}
97100

98101
if err := podman.RemoveImage(image, rmiFlags.forceDelete); err != nil {

src/pkg/podman/podman.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,12 @@ func IsToolboxImage(image string) (bool, error) {
352352
}
353353

354354
if info["Labels"] == nil {
355-
return false, fmt.Errorf("%s is not a Toolbx image", image)
355+
return false, nil
356356
}
357357

358358
labels := info["Labels"].(map[string]interface{})
359359
if labels["com.github.containers.toolbox"] != "true" && labels["com.github.debarshiray.toolbox"] != "true" {
360-
return false, fmt.Errorf("%s is not a Toolbx image", image)
360+
return false, nil
361361
}
362362

363363
return true, nil

0 commit comments

Comments
 (0)