From 93358ef915f639e52088b0f6aec52e77d3da0af7 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Wed, 5 Feb 2020 12:07:44 +0100 Subject: Refactor image tree for API usage Signed-off-by: Sascha Grunert --- pkg/varlinkapi/images.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'pkg/varlinkapi') diff --git a/pkg/varlinkapi/images.go b/pkg/varlinkapi/images.go index b144bfa5e..c4809f16b 100644 --- a/pkg/varlinkapi/images.go +++ b/pkg/varlinkapi/images.go @@ -1016,3 +1016,17 @@ func (i *LibpodAPI) BuildImageHierarchyMap(call iopodman.VarlinkCall, name strin } return call.ReplyBuildImageHierarchyMap(string(b)) } + +// ImageTree returns the image tree string for the provided image name or ID +func (i *LibpodAPI) ImageTree(call iopodman.VarlinkCall, nameOrID string, whatRequires bool) error { + img, err := i.Runtime.ImageRuntime().NewFromLocal(nameOrID) + if err != nil { + return call.ReplyErrorOccurred(err.Error()) + } + + tree, err := img.GenerateTree(whatRequires) + if err != nil { + return call.ReplyErrorOccurred(err.Error()) + } + return call.ReplyImageTree(tree) +} -- cgit v1.2.3-54-g00ecf