Skip to content

Commit

Permalink
manifest: rm should remove only manifests not referenced images.
Browse files Browse the repository at this point in the history
Following commit makes sure that `buildah manifest rm <list>` only removes
the manifest list not referenced images.

Signed-off-by: Aditya Rajan <[email protected]>
  • Loading branch information
flouthoc committed Sep 2, 2021
1 parent 36b74ad commit c84c568
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/buildah/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 14 additions & 0 deletions tests/rm.bats
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,17 @@ 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"
run_buildah manifest rm manifestsample
# Since actual list is getting removed it will also print the image id of list
# So check for substring instead of exact match
expect_output --substring "untagged: localhost/manifestsample:latest"
}

0 comments on commit c84c568

Please sign in to comment.