Skip to content

Commit

Permalink
Merge pull request containers#3492 from flouthoc/manifest-rm-only-man…
Browse files Browse the repository at this point in the history
…ifest

manifest: Make sure manifest `rm` only removes manifests not referenced images.
  • Loading branch information
openshift-merge-robot authored Sep 4, 2021
2 parents e1f7471 + f037ce4 commit b6c883d
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 12 deletions.
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.13
require (
github.com/containerd/containerd v1.5.5
github.com/containernetworking/cni v0.8.1
github.com/containers/common v0.43.3-0.20210830085322-6143ffe54e5f
github.com/containers/common v0.43.3-0.20210902095222-a7acc160fb25
github.com/containers/image/v5 v5.16.0
github.com/containers/ocicrypt v1.1.2
github.com/containers/storage v1.35.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ github.com/containernetworking/cni v0.8.1 h1:7zpDnQ3T3s4ucOuJ/ZCLrYBxzkg0AELFfII
github.com/containernetworking/cni v0.8.1/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ61X79hmU3w8FmsY=
github.com/containernetworking/plugins v0.8.6/go.mod h1:qnw5mN19D8fIwkqW7oHHYDHVlzhJpcY6TQxn/fUyDDM=
github.com/containernetworking/plugins v0.9.1/go.mod h1:xP/idU2ldlzN6m4p5LmGiwRDjeJr6FLK6vuiUwoH7P8=
github.com/containers/common v0.43.3-0.20210830085322-6143ffe54e5f h1:aK7C516naCNpgksPPM9qAs5wgfmeeKtp1NlLREvMy7A=
github.com/containers/common v0.43.3-0.20210830085322-6143ffe54e5f/go.mod h1:NIymxA8e3mUVnLoeGFoDgIrJeUmVA/djOqgMmO112Qw=
github.com/containers/common v0.43.3-0.20210902095222-a7acc160fb25 h1:zcFtn+MuCwpywchrRtZjFQxTJIcNb9vjlIeZktYgSzQ=
github.com/containers/common v0.43.3-0.20210902095222-a7acc160fb25/go.mod h1:NIymxA8e3mUVnLoeGFoDgIrJeUmVA/djOqgMmO112Qw=
github.com/containers/image/v5 v5.16.0 h1:WQcNSzb7+ngS2cfynx0vUwhk+scpgiKlldVcsF8GPbI=
github.com/containers/image/v5 v5.16.0/go.mod h1:XgTpfAPLRGOd1XYyCU5cISFr777bLmOerCSpt/v7+Q4=
github.com/containers/libtrust v0.0.0-20190913040956-14b96171aa3b h1:Q8ePgVfHDplZ7U33NwHZkrVELsZP5fYj9pM5WBZB2GE=
Expand Down
17 changes: 17 additions & 0 deletions tests/rm.bats
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,20 @@ 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"
# Check if busybox is still there
run_buildah images
expect_output --substring "busybox"
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ github.com/containernetworking/cni/pkg/types/020
github.com/containernetworking/cni/pkg/types/current
github.com/containernetworking/cni/pkg/utils
github.com/containernetworking/cni/pkg/version
# github.com/containers/common v0.43.3-0.20210830085322-6143ffe54e5f
# github.com/containers/common v0.43.3-0.20210902095222-a7acc160fb25
github.com/containers/common/libimage
github.com/containers/common/libimage/manifests
github.com/containers/common/pkg/apparmor
Expand Down

0 comments on commit b6c883d

Please sign in to comment.