diff options
author | openshift-ci[bot] <75433959+openshift-ci[bot]@users.noreply.github.com> | 2022-06-29 10:44:56 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-29 10:44:56 +0000 |
commit | 6e910a08dbbf5f74b7aeb184669c94e4c4d08228 (patch) | |
tree | 8d390f8d4c98997e455ac7e086a3cdf2163e48cf /pkg/bindings | |
parent | d7121b000fbdda8b28343a58a4f2c0009286e633 (diff) | |
parent | 5790caaef769ff3dcf8b9ebf43fb6c61d17618bf (diff) | |
download | podman-6e910a08dbbf5f74b7aeb184669c94e4c4d08228.tar.gz podman-6e910a08dbbf5f74b7aeb184669c94e4c4d08228.tar.bz2 podman-6e910a08dbbf5f74b7aeb184669c94e4c4d08228.zip |
Merge pull request #14740 from flouthoc/bindings-remove-manifest
bindings: Add support for `Delete` for deleting manifest list from local storage.
Diffstat (limited to 'pkg/bindings')
-rw-r--r-- | pkg/bindings/manifests/manifests.go | 20 | ||||
-rw-r--r-- | pkg/bindings/test/manifests_test.go | 13 |
2 files changed, 33 insertions, 0 deletions
diff --git a/pkg/bindings/manifests/manifests.go b/pkg/bindings/manifests/manifests.go index feff5d6e8..aaa26d7e1 100644 --- a/pkg/bindings/manifests/manifests.go +++ b/pkg/bindings/manifests/manifests.go @@ -117,6 +117,26 @@ func Remove(ctx context.Context, name, digest string, _ *RemoveOptions) (string, return Modify(ctx, name, []string{digest}, optionsv4) } +// Delete removes specified manifest from local storage. +func Delete(ctx context.Context, name string) (*entities.ManifestRemoveReport, error) { + var report entities.ManifestRemoveReport + conn, err := bindings.GetClient(ctx) + if err != nil { + return nil, err + } + response, err := conn.DoRequest(ctx, nil, http.MethodDelete, "/manifests/%s", nil, nil, name) + if err != nil { + return nil, err + } + defer response.Body.Close() + + if err := response.Process(&report); err != nil { + return nil, err + } + + return &report, errorhandling.JoinErrors(errorhandling.StringsToErrors(report.Errors)) +} + // Push takes a manifest list and pushes to a destination. If the destination is not specified, // the name will be used instead. If the optional all boolean is specified, all images specified // in the list will be pushed as well. diff --git a/pkg/bindings/test/manifests_test.go b/pkg/bindings/test/manifests_test.go index e6c93817d..6a34ef5a6 100644 --- a/pkg/bindings/test/manifests_test.go +++ b/pkg/bindings/test/manifests_test.go @@ -62,6 +62,19 @@ var _ = Describe("podman manifest", func() { Expect(len(list.Manifests)).To(BeNumerically("==", 1)) }) + It("delete manifest", func() { + id, err := manifests.Create(bt.conn, "quay.io/libpod/foobar:latest", []string{}, nil) + Expect(err).ToNot(HaveOccurred(), err) + list, err := manifests.Inspect(bt.conn, id, nil) + Expect(err).ToNot(HaveOccurred()) + + Expect(len(list.Manifests)).To(BeZero()) + + removeReport, err := manifests.Delete(bt.conn, "quay.io/libpod/foobar:latest") + Expect(err).ToNot(HaveOccurred()) + Expect(len(removeReport.Deleted)).To(BeNumerically("==", 1)) + }) + It("inspect", func() { _, err := manifests.Inspect(bt.conn, "larry", nil) Expect(err).To(HaveOccurred()) |