summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authoropenshift-ci[bot] <75433959+openshift-ci[bot]@users.noreply.github.com>2022-08-05 14:48:18 +0000
committerGitHub <noreply@github.com>2022-08-05 14:48:18 +0000
commit66c246d2c13edb893368fef4ba3a9770c00f8f3b (patch)
treef879331b8c4e8312e9a422b9a111aaa240b5db9a /pkg
parentff144e085e0e0b90b9bed4ce78cce014bcc672c2 (diff)
parentcc8e4d5fec571d6bd69d3d2f8189e945b621ba7b (diff)
downloadpodman-66c246d2c13edb893368fef4ba3a9770c00f8f3b.tar.gz
podman-66c246d2c13edb893368fef4ba3a9770c00f8f3b.tar.bz2
podman-66c246d2c13edb893368fef4ba3a9770c00f8f3b.zip
Merge pull request #15093 from karthikelango137/rmiNoPrune1
remove image podman no prune
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/handlers/libpod/images.go3
-rw-r--r--pkg/bindings/images/types.go2
-rw-r--r--pkg/bindings/images/types_remove_options.go15
-rw-r--r--pkg/domain/entities/images.go2
-rw-r--r--pkg/domain/infra/abi/images.go3
-rw-r--r--pkg/domain/infra/tunnel/images.go2
6 files changed, 24 insertions, 3 deletions
diff --git a/pkg/api/handlers/libpod/images.go b/pkg/api/handlers/libpod/images.go
index 67943ecf1..bccaad932 100644
--- a/pkg/api/handlers/libpod/images.go
+++ b/pkg/api/handlers/libpod/images.go
@@ -547,6 +547,7 @@ func ImagesBatchRemove(w http.ResponseWriter, r *http.Request) {
Ignore bool `schema:"ignore"`
LookupManifest bool `schema:"lookupManifest"`
Images []string `schema:"images"`
+ NoPrune bool `schema:"noprune"`
}{}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
@@ -554,7 +555,7 @@ func ImagesBatchRemove(w http.ResponseWriter, r *http.Request) {
return
}
- opts := entities.ImageRemoveOptions{All: query.All, Force: query.Force, Ignore: query.Ignore, LookupManifest: query.LookupManifest}
+ opts := entities.ImageRemoveOptions{All: query.All, Force: query.Force, Ignore: query.Ignore, LookupManifest: query.LookupManifest, NoPrune: query.NoPrune}
imageEngine := abi.ImageEngine{Libpod: runtime}
rmReport, rmErrors := imageEngine.Remove(r.Context(), query.Images, opts)
strErrs := errorhandling.ErrorsToStrings(rmErrors)
diff --git a/pkg/bindings/images/types.go b/pkg/bindings/images/types.go
index 0664afc1b..9783a8e18 100644
--- a/pkg/bindings/images/types.go
+++ b/pkg/bindings/images/types.go
@@ -15,6 +15,8 @@ type RemoveOptions struct {
Ignore *bool
// Confirms if given name is a manifest list and removes it, otherwise returns error.
LookupManifest *bool
+ // Does not remove dangling parent images
+ NoPrune *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 559ebcfd5..8972ac93c 100644
--- a/pkg/bindings/images/types_remove_options.go
+++ b/pkg/bindings/images/types_remove_options.go
@@ -76,3 +76,18 @@ func (o *RemoveOptions) GetLookupManifest() bool {
}
return *o.LookupManifest
}
+
+// WithNoPrune set field NoPrune to given value
+func (o *RemoveOptions) WithNoPrune(value bool) *RemoveOptions {
+ o.NoPrune = &value
+ return o
+}
+
+// GetNoPrune returns value of field NoPrune
+func (o *RemoveOptions) GetNoPrune() bool {
+ if o.NoPrune == nil {
+ var z bool
+ return z
+ }
+ return *o.NoPrune
+}
diff --git a/pkg/domain/entities/images.go b/pkg/domain/entities/images.go
index dad2dc6cc..21c1372b9 100644
--- a/pkg/domain/entities/images.go
+++ b/pkg/domain/entities/images.go
@@ -94,6 +94,8 @@ type ImageRemoveOptions struct {
Ignore bool
// Confirms if given name is a manifest list and removes it, otherwise returns error.
LookupManifest bool
+ // NoPrune will not remove dangling images
+ NoPrune bool
}
// ImageRemoveReport is the response for removing one or more image(s) from storage
diff --git a/pkg/domain/infra/abi/images.go b/pkg/domain/infra/abi/images.go
index 94178a8e2..1f34cbd01 100644
--- a/pkg/domain/infra/abi/images.go
+++ b/pkg/domain/infra/abi/images.go
@@ -565,6 +565,7 @@ func (ir *ImageEngine) Remove(ctx context.Context, images []string, opts entitie
libimageOptions.Force = opts.Force
libimageOptions.Ignore = opts.Ignore
libimageOptions.LookupManifest = opts.LookupManifest
+ libimageOptions.NoPrune = opts.NoPrune
if !opts.All {
libimageOptions.Filters = append(libimageOptions.Filters, "intermediate=false")
}
@@ -581,7 +582,7 @@ func (ir *ImageEngine) Remove(ctx context.Context, images []string, opts entitie
rmErrors = libimageErrors
- return
+ return report, rmErrors
}
// Shutdown Libpod engine
diff --git a/pkg/domain/infra/tunnel/images.go b/pkg/domain/infra/tunnel/images.go
index 4f79325fd..4fecefaa3 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).WithLookupManifest(opts.LookupManifest)
+ options := new(images.RemoveOptions).WithForce(opts.Force).WithIgnore(opts.Ignore).WithAll(opts.All).WithLookupManifest(opts.LookupManifest).WithNoPrune(opts.NoPrune)
return images.Remove(ir.ClientCtx, imagesArg, options)
}