forked from containers/common
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request containers#630 from vrothberg/fix-rm-force
libimage: force remove: only untag on multi tag image
- Loading branch information
Showing
8 changed files
with
83 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package libimage | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"testing" | ||
|
||
"github.com/containers/common/pkg/config" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestRemoveImages(t *testing.T) { | ||
// Note: this will resolve pull from the GCR registry (see | ||
// testdata/registries.conf). | ||
busyboxLatest := "docker.io/library/busybox:latest" | ||
|
||
runtime, cleanup := testNewRuntime(t) | ||
defer cleanup() | ||
ctx := context.Background() | ||
|
||
pullOptions := &PullOptions{} | ||
pullOptions.Writer = os.Stdout | ||
pulledImages, err := runtime.Pull(ctx, busyboxLatest, config.PullPolicyAlways, pullOptions) | ||
require.NoError(t, err) | ||
require.Len(t, pulledImages, 1) | ||
|
||
err = pulledImages[0].Tag("foobar") | ||
require.NoError(t, err) | ||
|
||
// containers/podman/issues/10685 - force removal on image with | ||
// multiple tags will only untag but not remove all tags including the | ||
// image. | ||
rmReports, rmErrors := runtime.RemoveImages(ctx, []string{"foobar"}, &RemoveImagesOptions{Force: true}) | ||
require.Nil(t, rmErrors) | ||
require.Len(t, rmReports, 1) | ||
require.Equal(t, pulledImages[0].ID(), rmReports[0].ID) | ||
require.False(t, rmReports[0].Removed) | ||
require.Equal(t, []string{"localhost/foobar:latest"}, rmReports[0].Untagged) | ||
|
||
// The busybox image is still present even if foobar was force removed. | ||
exists, err := runtime.Exists(busyboxLatest) | ||
require.NoError(t, err) | ||
require.True(t, exists) | ||
} |
47 changes: 23 additions & 24 deletions
47
vendor/github.com/containers/image/v5/storage/storage_image.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
vendor/github.com/containers/image/v5/version/version.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters