Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 8f246ae

Browse files
Add a new column in the list command, showing the application reference, or nothing if built locally
Signed-off-by: Silvin Lubecki <[email protected]>
1 parent 9873c34 commit 8f246ae

File tree

3 files changed

+28
-20
lines changed

3 files changed

+28
-20
lines changed

e2e/commands_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,8 @@ func testDockerAppLifecycle(t *testing.T, useBindMount bool) {
325325
cmd.Command = dockerCli.Command("app", "list")
326326
checkContains(t, icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(),
327327
[]string{
328-
`INSTALLATION\s+APPLICATION\s+LAST ACTION\s+RESULT\s+CREATED\s+MODIFIED`,
329-
fmt.Sprintf(`%s\s+simple \(1.1.0-beta1\)\s+install\s+failure\s+.+second?\s+.+second`, appName),
328+
`INSTALLATION\s+APPLICATION\s+LAST ACTION\s+RESULT\s+CREATED\s+MODIFIED\s+REFERENCE`,
329+
fmt.Sprintf(`%s\s+simple \(1.1.0-beta1\)\s+install\s+failure\s+.+second[s]?\s+.+second[s]?\s+`, appName),
330330
})
331331

332332
// Upgrading a failed installation is not allowed
@@ -361,8 +361,8 @@ func testDockerAppLifecycle(t *testing.T, useBindMount bool) {
361361
cmd.Command = dockerCli.Command("app", "list")
362362
checkContains(t, icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(),
363363
[]string{
364-
`INSTALLATION\s+APPLICATION\s+LAST ACTION\s+RESULT\s+CREATED\s+MODIFIED`,
365-
fmt.Sprintf(`%s\s+simple \(1.1.0-beta1\)\s+install\s+success\s+.+second.\s+.+second`, appName),
364+
`INSTALLATION\s+APPLICATION\s+LAST ACTION\s+RESULT\s+CREATED\s+MODIFIED\s+REFERENCE`,
365+
fmt.Sprintf(`%s\s+simple \(1.1.0-beta1\)\s+install\s+success\s+.+second[s]?\s+.+second[s]?\s+`, appName),
366366
})
367367

368368
// Installing again the same application is forbidden

e2e/pushpull_test.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,20 +104,28 @@ func TestPushPullInstall(t *testing.T) {
104104
runWithDindSwarmAndRegistry(t, func(info dindSwarmAndRegistryInfo) {
105105
cmd := info.configuredCmd
106106
ref := info.registryAddress + "/test/push-pull"
107-
cmd.Command = dockerCli.Command("app", "push", "--tag", ref, "--insecure-registries="+info.registryAddress, filepath.Join("testdata", "push-pull", "push-pull.dockerapp"))
107+
tag := ":v.0.0.1"
108+
cmd.Command = dockerCli.Command("app", "push", "--tag", ref+tag, "--insecure-registries="+info.registryAddress, filepath.Join("testdata", "push-pull", "push-pull.dockerapp"))
108109
icmd.RunCmd(cmd).Assert(t, icmd.Success)
109-
cmd.Command = dockerCli.Command("app", "pull", ref, "--insecure-registries="+info.registryAddress)
110+
cmd.Command = dockerCli.Command("app", "pull", ref+tag, "--insecure-registries="+info.registryAddress)
110111
icmd.RunCmd(cmd).Assert(t, icmd.Success)
111112

112113
// stop the registry
113114
info.stopRegistry()
114115

115116
// install without --pull should succeed (rely on local store)
116-
cmd.Command = dockerCli.Command("app", "install", "--insecure-registries="+info.registryAddress, ref, "--name", t.Name())
117+
cmd.Command = dockerCli.Command("app", "install", "--insecure-registries="+info.registryAddress, ref+tag, "--name", t.Name())
117118
icmd.RunCmd(cmd).Assert(t, icmd.Success)
118119
cmd.Command = dockerCli.Command("service", "ls")
119120
assert.Check(t, cmp.Contains(icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(), ref))
120121

122+
// listing the installed application shows the pulled application reference
123+
cmd.Command = dockerCli.Command("app", "list")
124+
checkContains(t, icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(),
125+
[]string{
126+
fmt.Sprintf(`%s\s+push-pull \(1.1.0-beta1\)\s+install\s+success\s+.+second[s]?\s+.+second[s]?\s+%s`, t.Name(), ref+tag),
127+
})
128+
121129
// install with --pull should fail (registry is stopped)
122130
cmd.Command = dockerCli.Command("app", "install", "--pull", "--insecure-registries="+info.registryAddress, ref, "--name", t.Name()+"2")
123131
assert.Check(t, cmp.Contains(icmd.RunCmd(cmd).Assert(t, icmd.Expected{ExitCode: 1}).Combined(), "failed to resolve bundle manifest"))

internal/commands/list.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import (
77
"text/tabwriter"
88
"time"
99

10-
"github.com/deislabs/duffle/pkg/claim"
11-
1210
"github.com/docker/app/internal/store"
1311
"github.com/docker/cli/cli"
1412
"github.com/docker/cli/cli/command"
@@ -24,14 +22,16 @@ type listOptions struct {
2422
var (
2523
listColumns = []struct {
2624
header string
27-
value func(c *claim.Claim) string
25+
value func(i *store.Installation) string
2826
}{
29-
{"INSTALLATION", func(c *claim.Claim) string { return c.Name }},
30-
{"APPLICATION", func(c *claim.Claim) string { return fmt.Sprintf("%s (%s)", c.Bundle.Name, c.Bundle.Version) }},
31-
{"LAST ACTION", func(c *claim.Claim) string { return c.Result.Action }},
32-
{"RESULT", func(c *claim.Claim) string { return c.Result.Status }},
33-
{"CREATED", func(c *claim.Claim) string { return units.HumanDuration(time.Since(c.Created)) }},
34-
{"MODIFIED", func(c *claim.Claim) string { return units.HumanDuration(time.Since(c.Modified)) }}}
27+
{"INSTALLATION", func(i *store.Installation) string { return i.Name }},
28+
{"APPLICATION", func(i *store.Installation) string { return fmt.Sprintf("%s (%s)", i.Bundle.Name, i.Bundle.Version) }},
29+
{"LAST ACTION", func(i *store.Installation) string { return i.Result.Action }},
30+
{"RESULT", func(i *store.Installation) string { return i.Result.Status }},
31+
{"CREATED", func(i *store.Installation) string { return units.HumanDuration(time.Since(i.Created)) }},
32+
{"MODIFIED", func(i *store.Installation) string { return units.HumanDuration(time.Since(i.Modified)) }},
33+
{"REFERENCE", func(i *store.Installation) string { return i.Reference }},
34+
}
3535
)
3636

3737
func listCmd(dockerCli command.Cli) *cobra.Command {
@@ -70,12 +70,12 @@ func runList(dockerCli command.Cli, opts listOptions) error {
7070
w := tabwriter.NewWriter(dockerCli.Out(), 0, 0, 1, ' ', 0)
7171
printHeaders(w)
7272

73-
for _, c := range installations {
74-
installation, err := installationStore.Read(c)
73+
for _, name := range installations {
74+
installation, err := installationStore.Read(name)
7575
if err != nil {
7676
return err
7777
}
78-
printValues(w, &installation)
78+
printValues(w, installation)
7979
}
8080
return w.Flush()
8181
}
@@ -88,7 +88,7 @@ func printHeaders(w io.Writer) {
8888
fmt.Fprintln(w, strings.Join(headers, "\t"))
8989
}
9090

91-
func printValues(w io.Writer, installation *claim.Claim) {
91+
func printValues(w io.Writer, installation *store.Installation) {
9292
var values []string
9393
for _, column := range listColumns {
9494
values = append(values, column.value(installation))

0 commit comments

Comments
 (0)