aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-03-21 09:55:57 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-03-21 19:14:50 +0000
commitd0835493d51038dda2bc63530f4fb70ced9f98cf (patch)
treee8199183a90f2d09dd4eb1f7539031811503bddc /cmd/podman
parent3428de0672afcd94ce65d7c29fd23e44e7e2b465 (diff)
downloadpodman-d0835493d51038dda2bc63530f4fb70ced9f98cf.tar.gz
podman-d0835493d51038dda2bc63530f4fb70ced9f98cf.tar.bz2
podman-d0835493d51038dda2bc63530f4fb70ced9f98cf.zip
Migrate podman inspect and tag to image library
Signed-off-by: baude <bbaude@redhat.com> Closes: #525 Approved by: baude
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/create.go2
-rw-r--r--cmd/podman/inspect.go4
-rw-r--r--cmd/podman/run.go2
-rw-r--r--cmd/podman/tag.go47
4 files changed, 8 insertions, 47 deletions
diff --git a/cmd/podman/create.go b/cmd/podman/create.go
index 947f6d2a6..af065817f 100644
--- a/cmd/podman/create.go
+++ b/cmd/podman/create.go
@@ -180,7 +180,7 @@ func createCmd(c *cli.Context) error {
if err != nil {
return err
}
- data, err := libpod.GetImageData(newImage)
+ data, err := newImage.Inspect()
createConfig, err := parseCreateOpts(c, runtime, newImage.Names()[0], data)
if err != nil {
return err
diff --git a/cmd/podman/inspect.go b/cmd/podman/inspect.go
index b691b7a12..4c4154d88 100644
--- a/cmd/podman/inspect.go
+++ b/cmd/podman/inspect.go
@@ -133,7 +133,7 @@ func iterateInput(c *cli.Context, args []string, runtime *libpod.Runtime, inspec
inspectError = errors.Wrapf(err, "error getting image %q", input)
break
}
- data, err = libpod.GetImageData(image)
+ data, err = image.Inspect()
if err != nil {
inspectError = errors.Wrapf(err, "error parsing image data %q", image.ID())
break
@@ -146,7 +146,7 @@ func iterateInput(c *cli.Context, args []string, runtime *libpod.Runtime, inspec
inspectError = errors.Wrapf(err, "error getting image %q", input)
break
}
- data, err = libpod.GetImageData(image)
+ data, err = image.Inspect()
if err != nil {
inspectError = errors.Wrapf(err, "error parsing image data %q", image.ID())
break
diff --git a/cmd/podman/run.go b/cmd/podman/run.go
index f1e11f839..53b7083e3 100644
--- a/cmd/podman/run.go
+++ b/cmd/podman/run.go
@@ -54,7 +54,7 @@ func runCmd(c *cli.Context) error {
rtc := runtime.GetConfig()
newImage, err := runtime.ImageRuntime().New(c.Args()[0], rtc.SignaturePolicyPath, "", os.Stderr, nil, image.SigningOptions{})
- data, err := libpod.GetImageData(newImage)
+ data, err := newImage.Inspect()
if err != nil {
return err
}
diff --git a/cmd/podman/tag.go b/cmd/podman/tag.go
index b71ee97b8..d2a157e7f 100644
--- a/cmd/podman/tag.go
+++ b/cmd/podman/tag.go
@@ -1,10 +1,7 @@
package main
import (
- "github.com/containers/image/docker/reference"
- "github.com/containers/storage"
"github.com/pkg/errors"
- "github.com/projectatomic/libpod/libpod"
"github.com/urfave/cli"
)
@@ -30,51 +27,15 @@ func tagCmd(c *cli.Context) error {
}
defer runtime.Shutdown(false)
- newImage := runtime.NewImage(args[0])
- newImage.GetLocalImageName()
-
- img, err := runtime.GetImage(newImage.LocalName)
+ newImage, err := runtime.ImageRuntime().NewFromLocal(args[0])
if err != nil {
return err
}
- if img == nil {
- return errors.New("null image")
- }
- err = addImageNames(runtime, img, args[1:])
- if err != nil {
- return errors.Wrapf(err, "error adding names %v to image %q", args[1:], args[0])
- }
- return nil
-}
-func addImageNames(runtime *libpod.Runtime, image *storage.Image, addNames []string) error {
- // Add tags to the names if applicable
- names, err := expandedTags(addNames)
- if err != nil {
- return err
- }
- for _, name := range names {
- if err := runtime.TagImage(image, name); err != nil {
- return errors.Wrapf(err, "error adding name (%v) to image %q", name, image.ID)
+ for _, tagName := range args[1:] {
+ if err := newImage.TagImage(tagName); err != nil {
+ return errors.Wrapf(err, "error adding '%s' to image %q", tagName, newImage.InputName)
}
}
return nil
}
-
-func expandedTags(tags []string) ([]string, error) {
- expandedNames := []string{}
- for _, tag := range tags {
- var labelName string
- name, err := reference.Parse(tag)
- if err != nil {
- return nil, errors.Wrapf(err, "error parsing tag %q", name)
- }
- if _, ok := name.(reference.NamedTagged); ok {
- labelName = name.String()
- } else {
- labelName = name.String() + ":latest"
- }
- expandedNames = append(expandedNames, labelName)
- }
- return expandedNames, nil
-}