Skip to content

Commit

Permalink
manifest: Make sure manifest rm only removes manifests not referenced…
Browse files Browse the repository at this point in the history
… images.

Following PR 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 1, 2021
1 parent 2c09b07 commit 76f4b55
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 6 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: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ require (
)

replace github.com/sirupsen/logrus => github.com/sirupsen/logrus v1.4.2

replace github.com/containers/common => github.com/flouthoc/common v0.39.1-0.20210901071508-acd30a9fb740
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ 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/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 Expand Up @@ -316,6 +314,8 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.m
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/flouthoc/common v0.39.1-0.20210901071508-acd30a9fb740 h1:iUIuyZWpmWzdUs10dBdeebv+nK4Pdzr2HZaq89FAIcM=
github.com/flouthoc/common v0.39.1-0.20210901071508-acd30a9fb740/go.mod h1:NIymxA8e3mUVnLoeGFoDgIrJeUmVA/djOqgMmO112Qw=
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
Expand Down
10 changes: 10 additions & 0 deletions tests/rm.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

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.

15 changes: 14 additions & 1 deletion vendor/github.com/containers/common/libimage/runtime.go

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.20210830085322-6143ffe54e5f => github.com/flouthoc/common v0.39.1-0.20210901071508-acd30a9fb740
github.com/containers/common/libimage
github.com/containers/common/libimage/manifests
github.com/containers/common/pkg/apparmor
Expand Down

0 comments on commit 76f4b55

Please sign in to comment.