From 972df82632bf0840ac84756306ef607ea5be72d8 Mon Sep 17 00:00:00 2001 From: Miloslav Trmač Date: Fri, 7 Feb 2020 02:26:44 +0100 Subject: Introduce a Runtime.newImage constructor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... so that _all_ Image objects are created in a single place that is easy to update. Should not change behavior. Signed-off-by: Miloslav Trmač --- libpod/image/image.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'libpod/image/image.go') diff --git a/libpod/image/image.go b/libpod/image/image.go index 9cfcf3c67..f6792eeac 100644 --- a/libpod/image/image.go +++ b/libpod/image/image.go @@ -111,14 +111,18 @@ func setStore(options storage.StoreOptions) (storage.Store, error) { return store, nil } -// newFromStorage creates a new image object from a storage.Image -func (ir *Runtime) newFromStorage(img *storage.Image) *Image { - image := Image{ - InputName: img.ID, +// newImage creates a new image object given an "input name" and a storage.Image +func (ir *Runtime) newImage(inputName string, img *storage.Image) *Image { + return &Image{ + InputName: inputName, imageruntime: ir, image: img, } - return &image +} + +// newFromStorage creates a new image object from a storage.Image +func (ir *Runtime) newFromStorage(img *storage.Image) *Image { + return ir.newImage(img.ID, img) } // NewFromLocal creates a new image object that is intended @@ -129,11 +133,7 @@ func (ir *Runtime) NewFromLocal(name string) (*Image, error) { if err != nil { return nil, err } - return &Image{ - InputName: updatedInputName, - imageruntime: ir, - image: localImage, - }, nil + return ir.newImage(updatedInputName, localImage), nil } // New creates a new image object where the image could be local -- cgit v1.2.3-54-g00ecf