From 4f50ba41782ae0c4b1b25fd8cfa070d2cc2a461a Mon Sep 17 00:00:00 2001 From: Aditya Rajan Date: Thu, 2 Sep 2021 16:13:12 +0530 Subject: [PATCH] manifest: rm should remove only manifests not referenced images. Following commit makes sure that `buildah manifest rm ` only removes the manifest list not referenced images. Signed-off-by: Aditya Rajan --- cmd/buildah/manifest.go | 3 ++- tests/rm.bats | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/buildah/manifest.go b/cmd/buildah/manifest.go index f0b700362c5..9ce6a2e3015 100644 --- a/cmd/buildah/manifest.go +++ b/cmd/buildah/manifest.go @@ -459,7 +459,8 @@ func manifestRmCmd(c *cobra.Command, args []string) error { } options := &libimage.RemoveImagesOptions{ - Filters: []string{"readonly=false"}, + Filters: []string{"readonly=false"}, + LookupManifest: true, } rmiReports, rmiErrors := runtime.RemoveImages(context.Background(), args, options) for _, r := range rmiReports { diff --git a/tests/rm.bats b/tests/rm.bats index 31119049407..c1f05ba1f57 100644 --- a/tests/rm.bats +++ b/tests/rm.bats @@ -52,3 +52,13 @@ load helpers run_buildah 125 rm -a "$cid" expect_output --substring "when using the --all switch, you may not pass any containers names or IDs" } + +@test "remove a single tagged manifest list" { + _prefetch busybox + run_buildah manifest create manifestsample + run_buildah manifest add manifestsample busybox + run_buildah tag manifestsample manifestsample2 + run_buildah manifest rm manifestsample2 + # Output should only untag the listed manifest nothing else + expect_output "untagged: localhost/manifestsample2:latest" +}