diff options
author | Miloslav Trmač <mitr@redhat.com> | 2020-02-07 02:26:44 +0100 |
---|---|---|
committer | Miloslav Trmač <mitr@redhat.com> | 2020-02-07 23:36:01 +0100 |
commit | 972df82632bf0840ac84756306ef607ea5be72d8 (patch) | |
tree | efea7caddb15d20c95d73494a8ebcbe5e5af3534 | |
parent | 933edf4a3767a1431257ba9d2948821eba967c23 (diff) | |
download | podman-972df82632bf0840ac84756306ef607ea5be72d8.tar.gz podman-972df82632bf0840ac84756306ef607ea5be72d8.tar.bz2 podman-972df82632bf0840ac84756306ef607ea5be72d8.zip |
Introduce a Runtime.newImage constructor
... 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č <mitr@redhat.com>
-rw-r--r-- | libpod/image/image.go | 20 |
1 files changed, 10 insertions, 10 deletions
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 |