diff options
author | baude <bbaude@redhat.com> | 2018-01-23 10:34:00 -0600 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2018-01-23 11:49:21 -0600 |
commit | 49ec9b2e3e989413adafffbe023bb1729495ad88 (patch) | |
tree | 992501fc0b93ba0b90983e8353f4b07bd89f0d48 /cmd/podman/create.go | |
parent | a03e040f0bb1d32645879b2c8bec7c5e1fe0561f (diff) | |
download | podman-49ec9b2e3e989413adafffbe023bb1729495ad88.tar.gz podman-49ec9b2e3e989413adafffbe023bb1729495ad88.tar.bz2 podman-49ec9b2e3e989413adafffbe023bb1729495ad88.zip |
Streamline image resolution
When trying to determine if a user-provided string that describes
an image (ID, fq name, shortname, tagged), there were some
inefficiencies where we looked up images multiple times to derive
information about local images.
Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman/create.go')
-rw-r--r-- | cmd/podman/create.go | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/cmd/podman/create.go b/cmd/podman/create.go index 80cb7f432..e0825566a 100644 --- a/cmd/podman/create.go +++ b/cmd/podman/create.go @@ -370,10 +370,13 @@ func exposedPorts(c *cli.Context, imageExposedPorts map[string]struct{}) (map[na // default container runtime data out of it. imageData returns the data // to the caller. Example Data: Entrypoint, Env, WorkingDir, Labels ... func imageData(c *cli.Context, runtime *libpod.Runtime, image string) (string, string, *libpod.ImageData, error) { - var err error + var ( + err error + imageName, imageID string + ) // Deal with the image after all the args have been checked createImage := runtime.NewImage(image) - createImage.LocalName, _ = createImage.GetLocalImageName() + imageName, imageID, _ = createImage.GetLocalImageName() if createImage.LocalName == "" { // The image wasnt found by the user input'd name or its fqname // Pull the image @@ -384,31 +387,14 @@ func imageData(c *cli.Context, runtime *libpod.Runtime, image string) (string, s createImage.Pull(writer) } - var imageName string - if createImage.LocalName != "" { - nameIsID, err := runtime.IsImageID(createImage.LocalName) - if err != nil { - return "", "", nil, err - } - if nameIsID { - // If the input from the user is an ID, then we need to get the image - // name for cstorage - createImage.LocalName, err = createImage.GetNameByID() - if err != nil { - return "", "", nil, err - } - } - imageName = createImage.LocalName - } else { + createImage.LocalName = imageName + if imageName == "" { imageName, err = createImage.GetFQName() + _, imageID, _ = createImage.GetLocalImageName() } if err != nil { return "", "", nil, err } - imageID, err := createImage.GetImageID() - if err != nil { - return "", "", nil, err - } storageImage, err := runtime.GetImage(imageName) if err != nil { return "", "", nil, errors.Wrapf(err, "error getting storage image %q", image) |