diff options
author | Sujil02 <sushah@redhat.com> | 2020-04-29 22:41:56 -0400 |
---|---|---|
committer | Sujil02 <sushah@redhat.com> | 2020-05-01 13:57:16 -0400 |
commit | b94862171b29dbef4cd780e4b1746d97f62f7a94 (patch) | |
tree | 6d64486633a4ebc208f31431c81f1932ade979f4 /pkg/domain/infra/abi/system.go | |
parent | 2f3762eb911258016581187f072a24ac2724be3b (diff) | |
download | podman-b94862171b29dbef4cd780e4b1746d97f62f7a94.tar.gz podman-b94862171b29dbef4cd780e4b1746d97f62f7a94.tar.bz2 podman-b94862171b29dbef4cd780e4b1746d97f62f7a94.zip |
And system prune feature for v2.
Adds podman system prune for v2.
Refactoring for code reuse from pods containers images and volume prune.
Adds and enables testcases to support the added feature.
Signed-off-by: Sujil02 <sushah@redhat.com>
Diffstat (limited to 'pkg/domain/infra/abi/system.go')
-rw-r--r-- | pkg/domain/infra/abi/system.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/pkg/domain/infra/abi/system.go b/pkg/domain/infra/abi/system.go index e5c109ee6..ab1b282d8 100644 --- a/pkg/domain/infra/abi/system.go +++ b/pkg/domain/infra/abi/system.go @@ -175,3 +175,41 @@ func setUMask() { // nolint:deadcode,unused func checkInput() error { // nolint:deadcode,unused return nil } + +// SystemPrune removes unsed data from the system. Pruning pods, containers, volumes and images. +func (ic *ContainerEngine) SystemPrune(ctx context.Context, options entities.SystemPruneOptions) (*entities.SystemPruneReport, error) { + var systemPruneReport = new(entities.SystemPruneReport) + podPruneReport, err := ic.prunePodHelper(ctx) + if err != nil { + return nil, err + } + systemPruneReport.PodPruneReport = podPruneReport + + containerPruneReport, err := ic.pruneContainersHelper(ctx, nil) + if err != nil { + return nil, err + } + systemPruneReport.ContainerPruneReport = containerPruneReport + + results, err := ic.Libpod.ImageRuntime().PruneImages(ctx, options.All, nil) + if err != nil { + return nil, err + } + report := entities.ImagePruneReport{ + Report: entities.Report{ + Id: results, + Err: nil, + }, + } + + systemPruneReport.ImagePruneReport = &report + + if options.Volume { + volumePruneReport, err := ic.pruneVolumesHelper(ctx) + if err != nil { + return nil, err + } + systemPruneReport.VolumePruneReport = volumePruneReport + } + return systemPruneReport, nil +} |