summaryrefslogtreecommitdiff
path: root/cmd/kpod
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2017-11-27 17:11:50 -0500
committerGitHub <noreply@github.com>2017-11-27 17:11:50 -0500
commitda44ec438dd854dd7cd0d0eae1e37bf41cfe4929 (patch)
tree8e4f6052f45feccd75904767de6ef918e9575e17 /cmd/kpod
parent55167ef9828045f8f998286ffa76cad13c4c7da1 (diff)
parentc5b09d0a3574903c4044a137d5f2dc99c858e5a0 (diff)
downloadpodman-da44ec438dd854dd7cd0d0eae1e37bf41cfe4929.tar.gz
podman-da44ec438dd854dd7cd0d0eae1e37bf41cfe4929.tar.bz2
podman-da44ec438dd854dd7cd0d0eae1e37bf41cfe4929.zip
Merge pull request #80 from umohnani8/kpod_images
Fix output of kpod images
Diffstat (limited to 'cmd/kpod')
-rw-r--r--cmd/kpod/history.go2
-rw-r--r--cmd/kpod/images.go63
2 files changed, 36 insertions, 29 deletions
diff --git a/cmd/kpod/history.go b/cmd/kpod/history.go
index c21c1e338..eba5b8b35 100644
--- a/cmd/kpod/history.go
+++ b/cmd/kpod/history.go
@@ -16,7 +16,7 @@ import (
const (
createdByTruncLength = 45
- idTruncLength = 13
+ idTruncLength = 12
)
// historyTemplateParams stores info about each layer
diff --git a/cmd/kpod/images.go b/cmd/kpod/images.go
index 0eac22864..4ab44365f 100644
--- a/cmd/kpod/images.go
+++ b/cmd/kpod/images.go
@@ -18,19 +18,20 @@ import (
)
type imagesTemplateParams struct {
- ID string
- Name string
- Digest digest.Digest
- CreatedAt string
- Size string
+ Repository string
+ Tag string
+ ID string
+ Digest digest.Digest
+ Created string
+ Size string
}
type imagesJSONParams struct {
- ID string `json:"id"`
- Name []string `json:"names"`
- Digest digest.Digest `json:"digest"`
- CreatedAt time.Time `json:"created"`
- Size int64 `json:"size"`
+ ID string `json:"id"`
+ Name []string `json:"names"`
+ Digest digest.Digest `json:"digest"`
+ Created time.Time `json:"created"`
+ Size int64 `json:"size"`
}
type imagesOptions struct {
@@ -139,14 +140,14 @@ func genImagesFormat(quiet, noHeading, digests bool) (format string) {
if quiet {
return formats.IDString
}
- format = "table {{.ID}}\t{{.Name}}\t"
+ format = "table {{.Repository}}\t{{.Tag}}\t"
if noHeading {
- format = "{{.ID}}\t{{.Name}}\t"
+ format = "{{.Repository}}\t{{.Tag}}\t"
}
if digests {
format += "{{.Digest}}\t"
}
- format += "{{.CreatedAt}}\t{{.Size}}\t"
+ format += "{{.ID}}\t{{.Created}}\t{{.Size}}\t"
return
}
@@ -172,7 +173,7 @@ func (i *imagesTemplateParams) headerMap() map[string]string {
for i := 0; i < v.NumField(); i++ {
key := v.Type().Field(i).Name
value := key
- if value == "ID" || value == "Name" {
+ if value == "ID" {
value = "Image" + value
}
values[key] = strings.ToUpper(splitCamelCase(value))
@@ -191,14 +192,19 @@ func getImagesTemplateOutput(runtime *libpod.Runtime, images []*storage.Image, o
}
createdTime := img.Created
- imageID := img.ID
+ imageID := "sha256:" + img.ID
if !opts.noTrunc {
- imageID = imageID[:idTruncLength]
+ imageID = img.ID[:idTruncLength]
}
- imageName := "<none>"
+ repository := "<none>"
+ tag := "<none>"
if len(img.Names) > 0 {
- imageName = img.Names[0]
+ arr := strings.Split(img.Names[0], ":")
+ repository = arr[0]
+ if len(arr) == 2 {
+ tag = arr[1]
+ }
}
info, imageDigest, size, _ := runtime.InfoAndDigestAndSize(*img)
@@ -207,11 +213,12 @@ func getImagesTemplateOutput(runtime *libpod.Runtime, images []*storage.Image, o
}
params := imagesTemplateParams{
- ID: imageID,
- Name: imageName,
- Digest: imageDigest,
- CreatedAt: units.HumanDuration(time.Since((createdTime))) + " ago",
- Size: units.HumanSize(float64(size)),
+ Repository: repository,
+ Tag: tag,
+ ID: imageID,
+ Digest: imageDigest,
+ Created: units.HumanDuration(time.Since((createdTime))) + " ago",
+ Size: units.HumanSize(float64(size)),
}
imagesOutput = append(imagesOutput, params)
}
@@ -229,11 +236,11 @@ func getImagesJSONOutput(runtime *libpod.Runtime, images []*storage.Image) (imag
}
params := imagesJSONParams{
- ID: img.ID,
- Name: img.Names,
- Digest: imageDigest,
- CreatedAt: createdTime,
- Size: size,
+ ID: img.ID,
+ Name: img.Names,
+ Digest: imageDigest,
+ Created: createdTime,
+ Size: size,
}
imagesOutput = append(imagesOutput, params)
}