From 7459c48863acea8453e0800124006a90ca82f646 Mon Sep 17 00:00:00 2001 From: baude Date: Thu, 10 Jan 2019 14:39:39 -0600 Subject: Add varlink support for prune Add the ability to prune unused images using the varlink API. Signed-off-by: baude --- pkg/varlinkapi/images.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'pkg') diff --git a/pkg/varlinkapi/images.go b/pkg/varlinkapi/images.go index 8f8934025..4a4f20031 100644 --- a/pkg/varlinkapi/images.go +++ b/pkg/varlinkapi/images.go @@ -620,3 +620,21 @@ func (i *LibpodAPI) ContainerRunlabel(call iopodman.VarlinkCall, input iopodman. } return call.ReplyContainerRunlabel() } + +// ImagesPrune .... +func (i *LibpodAPI) ImagesPrune(call iopodman.VarlinkCall) error { + var ( + pruned []string + ) + pruneImages, err := i.Runtime.ImageRuntime().GetPruneImages() + if err != nil { + return err + } + for _, i := range pruneImages { + if err := i.Remove(true); err != nil { + return call.ReplyErrorOccurred(err.Error()) + } + pruned = append(pruned, i.ID()) + } + return call.ReplyImagesPrune(pruned) +} -- cgit v1.2.3-54-g00ecf