diff options
author | baude <bbaude@redhat.com> | 2018-03-28 09:15:55 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-03-29 16:31:43 +0000 |
commit | 1e59053cc55f82f21442aff6723c89e2af4ddffe (patch) | |
tree | db666eeea2aa844cad151e7004cee72ff48191ff /libpod/image/image.go | |
parent | 8a96b4acbc97d5c34ff0160ab1a1b585fdd5d156 (diff) | |
download | podman-1e59053cc55f82f21442aff6723c89e2af4ddffe.tar.gz podman-1e59053cc55f82f21442aff6723c89e2af4ddffe.tar.bz2 podman-1e59053cc55f82f21442aff6723c89e2af4ddffe.zip |
Allow sha256: prefix for input
We should allow users to pass in image ids with the sha256: prefix
for local images.
Resolves: #493
Signed-off-by: baude <bbaude@redhat.com>
Closes: #560
Approved by: baude
Diffstat (limited to 'libpod/image/image.go')
-rw-r--r-- | libpod/image/image.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libpod/image/image.go b/libpod/image/image.go index 5413c4e6b..c79844f7f 100644 --- a/libpod/image/image.go +++ b/libpod/image/image.go @@ -102,7 +102,6 @@ func (ir *Runtime) newFromStorage(img *storage.Image) *Image { // to only deal with local images already in the store (or // its aliases) func (ir *Runtime) NewFromLocal(name string) (*Image, error) { - image := Image{ InputName: name, Local: true, @@ -166,6 +165,14 @@ func (i *Image) reloadImage() error { return nil } +// stringSha256 strips sha256 from user input +func stripSha256(name string) string { + if strings.HasPrefix(name, "sha256:") && len(name) > 7 { + return name[7:] + } + return name +} + // getLocalImage resolves an unknown input describing an image and // returns a storage.Image or an error. It is used by NewFromLocal. func (i *Image) getLocalImage() (*storage.Image, error) { @@ -174,7 +181,7 @@ func (i *Image) getLocalImage() (*storage.Image, error) { return nil, errors.Errorf("input name is blank") } var taggedName string - img, err := i.imageruntime.getImage(i.InputName) + img, err := i.imageruntime.getImage(stripSha256(i.InputName)) if err == nil { return img.image, err } |