diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-05-01 21:08:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-01 21:08:50 +0200 |
commit | bffd3f5134b6c64dc53b7713bd064a9edd3ee466 (patch) | |
tree | e50040bd5304f82542c5d8e51cfff98ac8ffbdb9 /pkg/domain/infra/abi/system.go | |
parent | 95b9b72c0c0c6904ca35c97c76ee728b1750bf84 (diff) | |
parent | b94862171b29dbef4cd780e4b1746d97f62f7a94 (diff) | |
download | podman-bffd3f5134b6c64dc53b7713bd064a9edd3ee466.tar.gz podman-bffd3f5134b6c64dc53b7713bd064a9edd3ee466.tar.bz2 podman-bffd3f5134b6c64dc53b7713bd064a9edd3ee466.zip |
Merge pull request #6060 from sujil02/systemprune-v2
And system prune feature for v2.
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 +} |