Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
table minwidth is 20
Browse files Browse the repository at this point in the history
set by
cli/command/formatter/formatter.go#postFromat

Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof committed Nov 20, 2019
1 parent 04a69f8 commit f723638
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 31 deletions.
37 changes: 19 additions & 18 deletions e2e/images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ func TestImageList(t *testing.T) {

insertBundles(t, cmd)

expected := `REPOSITORY TAG APP IMAGE ID APP NAME CREATED
a-simple-app latest [a-f0-9]{12} simple [La-z0-9 ]+ ago
b-simple-app latest [a-f0-9]{12} simple [La-z0-9 ]+ ago
my.registry:5000/c-myapp latest [a-f0-9]{12} push-pull [La-z0-9 ]+ ago
expected := `REPOSITORY TAG APP IMAGE ID APP NAME CREATED
a-simple-app latest [a-f0-9]{12} simple [La-z0-9 ]+ ago[ ]*
b-simple-app latest [a-f0-9]{12} simple [La-z0-9 ]+ ago[ ]*
my.registry:5000/c-myapp latest [a-f0-9]{12} push-pull [La-z0-9 ]+ ago[ ]*
`

expectImageListOutput(t, cmd, expected)
})
}
Expand All @@ -87,10 +88,10 @@ func TestImageListDigests(t *testing.T) {
runWithDindSwarmAndRegistry(t, func(info dindSwarmAndRegistryInfo) {
cmd := info.configuredCmd
insertBundles(t, cmd)
expected := `REPOSITORY TAG DIGEST APP IMAGE ID APP NAME CREATED
a-simple-app latest <none> [a-f0-9]{12} simple [La-z0-9 ]+ ago
b-simple-app latest <none> [a-f0-9]{12} simple [La-z0-9 ]+ ago
my.registry:5000/c-myapp latest <none> [a-f0-9]{12} push-pull [La-z0-9 ]+ ago
expected := `REPOSITORY TAG DIGEST APP IMAGE ID APP NAME CREATED
a-simple-app latest <none> [a-f0-9]{12} simple [La-z0-9 ]+ ago[ ]*
b-simple-app latest <none> [a-f0-9]{12} simple [La-z0-9 ]+ ago[ ]*
my.registry:5000/c-myapp latest <none> [a-f0-9]{12} push-pull [La-z0-9 ]+ ago[ ]*
`
expectImageListDigestsOutput(t, cmd, expected)
})
Expand Down Expand Up @@ -121,7 +122,7 @@ Deleted: b-simple-app:latest`,
Err: `b-simple-app:latest: reference not found`,
})

expectedOutput := "REPOSITORY TAG APP IMAGE ID APP NAME CREATED\n"
expectedOutput := "REPOSITORY TAG APP IMAGE ID APP NAME CREATED \n"
expectImageListOutput(t, cmd, expectedOutput)
})
}
Expand All @@ -139,8 +140,8 @@ func TestImageTag(t *testing.T) {
cmd.Command = dockerCli.Command("app", "build", "--tag", "a-simple-app", filepath.Join("testdata", "simple"))
icmd.RunCmd(cmd).Assert(t, icmd.Success)

singleImageExpectation := `REPOSITORY TAG APP IMAGE ID APP NAME CREATED
a-simple-app latest [a-f0-9]{12} simple [La-z0-9 ]+ ago
singleImageExpectation := `REPOSITORY TAG APP IMAGE ID APP NAME CREATED
a-simple-app latest [a-f0-9]{12} simple [La-z0-9 ]+ ago[ ]*
`
expectImageListOutput(t, cmd, singleImageExpectation)

Expand Down Expand Up @@ -189,18 +190,18 @@ a-simple-app latest [a-f0-9]{12} simple [La-z0-9 ]+ ago
// tag image with only names
dockerAppImageTag("a-simple-app", "b-simple-app")
icmd.RunCmd(cmd).Assert(t, icmd.Success)
expectImageListOutput(t, cmd, `REPOSITORY TAG APP IMAGE ID APP NAME CREATED
a-simple-app latest [a-f0-9]{12} simple [La-z0-9 ]+ ago
b-simple-app latest [a-f0-9]{12} simple [La-z0-9 ]+ ago
expectImageListOutput(t, cmd, `REPOSITORY TAG APP IMAGE ID APP NAME CREATED
a-simple-app latest [a-f0-9]{12} simple [La-z0-9 ]+ ago[ ]*
b-simple-app latest [a-f0-9]{12} simple [La-z0-9 ]+ ago[ ]*
`)

// target tag
dockerAppImageTag("a-simple-app", "a-simple-app:0.1")
icmd.RunCmd(cmd).Assert(t, icmd.Success)
expectImageListOutput(t, cmd, `REPOSITORY TAG APP IMAGE ID APP NAME CREATED
a-simple-app 0.1 [a-f0-9]{12} simple [La-z0-9 ]+ ago
a-simple-app latest [a-f0-9]{12} simple [La-z0-9 ]+ ago
b-simple-app latest [a-f0-9]{12} simple [La-z0-9 ]+ ago
expectImageListOutput(t, cmd, `REPOSITORY TAG APP IMAGE ID APP NAME CREATED
a-simple-app latest [a-f0-9]{12} simple [La-z0-9 ]+ ago[ ]*
a-simple-app latest [a-f0-9]{12} simple [La-z0-9 ]+ ago[ ]*
b-simple-app latest [a-f0-9]{12} simple [La-z0-9 ]+ ago[ ]*
`)

// source tag
Expand Down
7 changes: 5 additions & 2 deletions internal/commands/image/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (

const (
defaultImageTableFormat = "table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.Name}}\t{{if .CreatedSince }}{{.CreatedSince}}{{else}}N/A{{end}}\t"
defaultImageTableFormatWithDigest = "table {{.Repository}}\t{{.Tag}}\t{{.Digest}}\t{{.ID}}{{.Name}}\t\t{{if .CreatedSince }}{{.CreatedSince}}{{else}}N/A{{end}}\t"
defaultImageTableFormatWithDigest = "table {{.Repository}}\t{{.Tag}}\t{{.Digest}}\t{{.ID}}\t{{.Name}}\t\t{{if .CreatedSince }}{{.CreatedSince}}{{else}}N/A{{end}}\t"

imageIDHeader = "APP ID"
imageIDHeader = "APP IMAGE ID"
repositoryHeader = "REPOSITORY"
tagHeader = "TAG"
digestHeader = "DIGEST"
Expand Down Expand Up @@ -112,6 +112,9 @@ func (c *imageContext) Tag() string {
}

func (c *imageContext) Digest() string {
if c.i.Digest == "" {
return "<none>"
}
return c.i.Digest
}

Expand Down
32 changes: 21 additions & 11 deletions internal/commands/image/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,29 +83,39 @@ func TestListCmd(t *testing.T) {
}{
{
name: "TestList",
expectedOutput: `REPOSITORY TAG APP IMAGE ID APP NAME CREATED
foo/bar <none> 3f825b2d0657 Digested App
foo/bar 1.0 9aae408ee04f Foo App
<none> <none> a855ac937f2e Quiet App
expectedOutput: `REPOSITORY TAG APP IMAGE ID APP NAME CREATED
foo/bar <none> 3f825b2d0657 Digested App N/A
foo/bar 1.0 9aae408ee04f Foo App N/A
<none> <none> a855ac937f2e Quiet App N/A
`,
options: imageListOption{},
options: imageListOption{format: "table"},
},
{
name: "TestTemplate",
expectedOutput: `APP IMAGE ID DIGEST
3f825b2d0657 sha256:b59492bb814012ca3d2ce0b6728242d96b4af41687cc82166a4b5d7f2d9fb865
9aae408ee04f <none>
a855ac937f2e sha256:a855ac937f2ed375ba4396bbc49c4093e124da933acd2713fb9bc17d7562a087
`,
options: imageListOption{format: "table {{.ID}}", digests: true},
},
{
name: "TestListWithDigests",
expectedOutput: `REPOSITORY TAG DIGEST APP IMAGE ID APP NAME CREATED
foo/bar <none> sha256:b59492bb814012ca3d2ce0b6728242d96b4af41687cc82166a4b5d7f2d9fb865 3f825b2d0657 Digested App
foo/bar 1.0 <none> 9aae408ee04f Foo App
<none> <none> sha256:a855ac937f2ed375ba4396bbc49c4093e124da933acd2713fb9bc17d7562a087 a855ac937f2e Quiet App
//nolint:lll
expectedOutput: `REPOSITORY TAG DIGEST APP IMAGE ID APP NAME CREATED
foo/bar <none> sha256:b59492bb814012ca3d2ce0b6728242d96b4af41687cc82166a4b5d7f2d9fb865 3f825b2d0657 Digested App N/A
foo/bar 1.0 <none> 9aae408ee04f Foo App N/A
<none> <none> sha256:a855ac937f2ed375ba4396bbc49c4093e124da933acd2713fb9bc17d7562a087 a855ac937f2e Quiet App N/A
`,
options: imageListOption{digests: true},
options: imageListOption{format: "table", digests: true},
},
{
name: "TestListWithQuiet",
expectedOutput: `3f825b2d0657
9aae408ee04f
a855ac937f2e
`,
options: imageListOption{quiet: true},
options: imageListOption{format: "table", quiet: true},
},
}

Expand Down

0 comments on commit f723638

Please sign in to comment.