summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorAditya R <arajan@redhat.com>2022-06-30 11:33:28 +0530
committerAditya R <arajan@redhat.com>2022-06-30 14:56:42 +0530
commit7bbfb3eb0d9c711332b5d96963bbc8db28bf6115 (patch)
treea06c4d46502c889f468e5ef3f1ec693331230662 /pkg
parent3426d56b92be2ac1c3cc62fc578e9cb6d64aca81 (diff)
downloadpodman-7bbfb3eb0d9c711332b5d96963bbc8db28bf6115.tar.gz
podman-7bbfb3eb0d9c711332b5d96963bbc8db28bf6115.tar.bz2
podman-7bbfb3eb0d9c711332b5d96963bbc8db28bf6115.zip
api,images: add support for LookupManifest to Image remove API
ImagesBatchRemoval and ImageRemoval now honors and accepts `LookupManifest` parameter which further tells libimage to resolve to manifest list if it exists instead of actual image. Following PR also makes `podman-remote manifest rm` functional which was broken till now. Closes: https://github.com/containers/podman/issues/14763 Signed-off-by: Aditya R <arajan@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/handlers/libpod/images.go16
-rw-r--r--pkg/api/server/register_images.go4
-rw-r--r--pkg/bindings/images/types.go2
-rw-r--r--pkg/bindings/images/types_remove_options.go15
-rw-r--r--pkg/domain/infra/tunnel/images.go2
5 files changed, 31 insertions, 8 deletions
diff --git a/pkg/api/handlers/libpod/images.go b/pkg/api/handlers/libpod/images.go
index 2e450051d..b71217efa 100644
--- a/pkg/api/handlers/libpod/images.go
+++ b/pkg/api/handlers/libpod/images.go
@@ -615,10 +615,11 @@ func ImagesBatchRemove(w http.ResponseWriter, r *http.Request) {
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
decoder := r.Context().Value(api.DecoderKey).(*schema.Decoder)
query := struct {
- All bool `schema:"all"`
- Force bool `schema:"force"`
- Ignore bool `schema:"ignore"`
- Images []string `schema:"images"`
+ All bool `schema:"all"`
+ Force bool `schema:"force"`
+ Ignore bool `schema:"ignore"`
+ LookupManifest bool `schema:"lookupManifest"`
+ Images []string `schema:"images"`
}{}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
@@ -626,7 +627,7 @@ func ImagesBatchRemove(w http.ResponseWriter, r *http.Request) {
return
}
- opts := entities.ImageRemoveOptions{All: query.All, Force: query.Force, Ignore: query.Ignore}
+ opts := entities.ImageRemoveOptions{All: query.All, Force: query.Force, Ignore: query.Ignore, LookupManifest: query.LookupManifest}
imageEngine := abi.ImageEngine{Libpod: runtime}
rmReport, rmErrors := imageEngine.Remove(r.Context(), query.Images, opts)
strErrs := errorhandling.ErrorsToStrings(rmErrors)
@@ -639,7 +640,8 @@ func ImagesRemove(w http.ResponseWriter, r *http.Request) {
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
decoder := r.Context().Value(api.DecoderKey).(*schema.Decoder)
query := struct {
- Force bool `schema:"force"`
+ Force bool `schema:"force"`
+ LookupManifest bool `schema:"lookupManifest"`
}{
Force: false,
}
@@ -649,7 +651,7 @@ func ImagesRemove(w http.ResponseWriter, r *http.Request) {
return
}
- opts := entities.ImageRemoveOptions{Force: query.Force}
+ opts := entities.ImageRemoveOptions{Force: query.Force, LookupManifest: query.LookupManifest}
imageEngine := abi.ImageEngine{Libpod: runtime}
rmReport, rmErrors := imageEngine.Remove(r.Context(), []string{utils.GetName(r)}, opts)
diff --git a/pkg/api/server/register_images.go b/pkg/api/server/register_images.go
index a9f9cb5b1..a2f46cb35 100644
--- a/pkg/api/server/register_images.go
+++ b/pkg/api/server/register_images.go
@@ -948,6 +948,10 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
// name: ignore
// description: Ignore if a specified image does not exist and do not throw an error.
// type: boolean
+ // - in: query
+ // name: lookupManifest
+ // description: Resolves to manifest list instead of image.
+ // type: boolean
// produces:
// - application/json
// responses:
diff --git a/pkg/bindings/images/types.go b/pkg/bindings/images/types.go
index 2c00c20cd..3728ae5c0 100644
--- a/pkg/bindings/images/types.go
+++ b/pkg/bindings/images/types.go
@@ -13,6 +13,8 @@ type RemoveOptions struct {
Force *bool
// Ignore if a specified image does not exist and do not throw an error.
Ignore *bool
+ // Confirms if given name is a manifest list and removes it, otherwise returns error.
+ LookupManifest *bool
}
//go:generate go run ../generator/generator.go DiffOptions
diff --git a/pkg/bindings/images/types_remove_options.go b/pkg/bindings/images/types_remove_options.go
index 613a33183..559ebcfd5 100644
--- a/pkg/bindings/images/types_remove_options.go
+++ b/pkg/bindings/images/types_remove_options.go
@@ -61,3 +61,18 @@ func (o *RemoveOptions) GetIgnore() bool {
}
return *o.Ignore
}
+
+// WithLookupManifest set field LookupManifest to given value
+func (o *RemoveOptions) WithLookupManifest(value bool) *RemoveOptions {
+ o.LookupManifest = &value
+ return o
+}
+
+// GetLookupManifest returns value of field LookupManifest
+func (o *RemoveOptions) GetLookupManifest() bool {
+ if o.LookupManifest == nil {
+ var z bool
+ return z
+ }
+ return *o.LookupManifest
+}
diff --git a/pkg/domain/infra/tunnel/images.go b/pkg/domain/infra/tunnel/images.go
index b81b64161..09f8ac4c3 100644
--- a/pkg/domain/infra/tunnel/images.go
+++ b/pkg/domain/infra/tunnel/images.go
@@ -28,7 +28,7 @@ func (ir *ImageEngine) Exists(_ context.Context, nameOrID string) (*entities.Boo
}
func (ir *ImageEngine) Remove(ctx context.Context, imagesArg []string, opts entities.ImageRemoveOptions) (*entities.ImageRemoveReport, []error) {
- options := new(images.RemoveOptions).WithForce(opts.Force).WithIgnore(opts.Ignore).WithAll(opts.All)
+ options := new(images.RemoveOptions).WithForce(opts.Force).WithIgnore(opts.Ignore).WithAll(opts.All).WithLookupManifest(opts.LookupManifest)
return images.Remove(ir.ClientCtx, imagesArg, options)
}