summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/create.go30
-rw-r--r--cmd/podman/ps.go45
2 files changed, 38 insertions, 37 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)
diff --git a/cmd/podman/ps.go b/cmd/podman/ps.go
index ef5d40c43..be6c5aef5 100644
--- a/cmd/podman/ps.go
+++ b/cmd/podman/ps.go
@@ -396,23 +396,38 @@ func (p *psTemplateParams) headerMap() map[string]string {
// getTemplateOutput returns the modified container information
func getTemplateOutput(containers []*libpod.Container, opts psOptions) ([]psTemplateParams, error) {
- var psOutput []psTemplateParams
- var status string
+ var (
+ psOutput []psTemplateParams
+ status, ctrID string
+ conConfig *libpod.ContainerConfig
+ conState libpod.ContainerStatus
+ err error
+ exitCode int32
+ pid int
+ )
+
for _, ctr := range containers {
- ctrID := ctr.ID()
- conConfig := ctr.Config()
- conState, err := ctr.State()
- if err != nil {
- return psOutput, errors.Wrapf(err, "unable to obtain container state")
- }
- exitCode, err := ctr.ExitCode()
- if err != nil {
- return psOutput, errors.Wrapf(err, "unable to obtain container exit code")
- }
- pid, err := ctr.PID()
- if err != nil {
- return psOutput, errors.Wrapf(err, "unable to obtain container pid")
+ batchErr := ctr.Batch(func(c *libpod.Container) error {
+ ctrID = c.ID()
+ conConfig = c.Config()
+ conState, err = c.State()
+ if err != nil {
+ return errors.Wrapf(err, "unable to obtain container state")
+ }
+ exitCode, err = c.ExitCode()
+ if err != nil {
+ return errors.Wrapf(err, "unable to obtain container exit code")
+ }
+ pid, err = c.PID()
+ if err != nil {
+ return errors.Wrapf(err, "unable to obtain container pid")
+ }
+ return nil
+ })
+ if batchErr != nil {
+ return nil, err
}
+
runningFor := units.HumanDuration(time.Since(conConfig.CreatedTime))
createdAt := runningFor + " ago"
imageName := conConfig.RootfsImageName