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

Commit 9a49da4

Browse files
authored
Merge pull request #757 from silvin-lubecki/ls-services-column
Add services column to docker app ls command
2 parents f38c337 + f84667a commit 9a49da4

File tree

15 files changed

+290
-117
lines changed

15 files changed

+290
-117
lines changed

e2e/commands_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ func TestDockerAppLifecycle(t *testing.T) {
316316
cmd.Command = dockerCli.Command("app", "ls")
317317
checkContains(t, icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(),
318318
[]string{
319-
`RUNNING APP\s+APP NAME\s+LAST ACTION\s+RESULT\s+CREATED\s+MODIFIED\s+REFERENCE`,
320-
fmt.Sprintf(`%s\s+simple \(1.1.0-beta1\)\s+install\s+failure\s+.+second[s]?\sago\s+.+second[s]?\sago\s+`, appName),
319+
`RUNNING APP\s+APP NAME\s+SERVICES\s+LAST ACTION\s+RESULT\s+CREATED\s+MODIFIED\s+REFERENCE`,
320+
fmt.Sprintf(`%s\s+simple \(1.1.0-beta1\)\s+0/3\s+install\s+failure\s+.+second[s]?\sago\s+.+second[s]?\sago\s+`, appName),
321321
})
322322

323323
// Upgrading a failed installation is not allowed
@@ -344,8 +344,8 @@ func TestDockerAppLifecycle(t *testing.T) {
344344
cmd.Command = dockerCli.Command("app", "ls")
345345
checkContains(t, icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(),
346346
[]string{
347-
`RUNNING APP\s+APP NAME\s+LAST ACTION\s+RESULT\s+CREATED\s+MODIFIED\s+REFERENCE`,
348-
fmt.Sprintf(`%s\s+simple \(1.1.0-beta1\)\s+install\s+success\s+.+second[s]?\sago\s+.+second[s]?\sago\s+`, appName),
347+
`RUNNING APP\s+APP NAME\s+SERVICES\s+LAST ACTION\s+RESULT\s+CREATED\s+MODIFIED\s+REFERENCE`,
348+
fmt.Sprintf(`%s\s+simple \(1.1.0-beta1\)\s+\d/3\s+install\s+success\s+.+second[s]?\sago\s+.+second[s]?\sago\s+`, appName),
349349
})
350350

351351
// Installing again the same application is forbidden

e2e/pushpull_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func TestPushPullInstall(t *testing.T) {
9191
cmd.Command = dockerCli.Command("app", "ls")
9292
checkContains(t, icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(),
9393
[]string{
94-
fmt.Sprintf(`%s\s+push-pull \(1.1.0-beta1\)\s+install\s+success\s+.+second[s]?\sago\s+.+second[s]?\sago\s+%s`, t.Name(), ref+tag),
94+
fmt.Sprintf(`%s\s+push-pull \(1.1.0-beta1\)\s+\d/1\s+install\s+success\s+.+second[s]?\sago\s+.+second[s]?\sago\s+%s`, t.Name(), ref+tag),
9595
})
9696

9797
// install should fail (registry is stopped)

e2e/testdata/plugin-usage.golden

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ Usage: docker app [OPTIONS] COMMAND
44
A tool to build, share and run a Docker App
55

66
Options:
7-
--version Print version information
7+
--installer-context string Context on which the installer image
8+
is ran (default "default")
9+
--version Print version information
810

911
Management Commands:
1012
image Manage App images

internal/cnab/driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func prepareDriver(dockerCli command.Cli, bindMount BindMount, stdout io.Writer)
119119
return d, errBuf
120120
}
121121

122-
func SetupDriver(installation *store2.Installation, dockerCli command.Cli, opts cliopts.InstallerContextOptions, stdout io.Writer) (driver.Driver, *bytes.Buffer, error) {
122+
func SetupDriver(installation *store2.Installation, dockerCli command.Cli, opts *cliopts.InstallerContextOptions, stdout io.Writer) (driver.Driver, *bytes.Buffer, error) {
123123
dockerCli, err := opts.SetInstallerContext(dockerCli)
124124
if err != nil {
125125
return nil, nil, err

internal/commands/image/command.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package image
22

33
import (
4+
"github.com/docker/app/internal/cliopts"
45
"github.com/docker/cli/cli/command"
56
"github.com/spf13/cobra"
67
)
78

89
// Cmd is the image top level command
9-
func Cmd(dockerCli command.Cli) *cobra.Command {
10+
func Cmd(dockerCli command.Cli, installerContext *cliopts.InstallerContextOptions) *cobra.Command {
1011
cmd := &cobra.Command{
1112
Short: "Manage App images",
1213
Use: "image",
@@ -16,8 +17,8 @@ func Cmd(dockerCli command.Cli) *cobra.Command {
1617
listCmd(dockerCli),
1718
rmCmd(),
1819
tagCmd(),
19-
inspectCmd(dockerCli),
20-
renderCmd(dockerCli),
20+
inspectCmd(dockerCli, installerContext),
21+
renderCmd(dockerCli, installerContext),
2122
)
2223

2324
return cmd

internal/commands/image/inspect.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import (
55
"io/ioutil"
66
"os"
77

8-
"github.com/docker/app/internal/cliopts"
9-
108
"github.com/deislabs/cnab-go/action"
119
"github.com/docker/app/internal"
10+
"github.com/docker/app/internal/cliopts"
1211
"github.com/docker/app/internal/cnab"
1312
"github.com/docker/app/internal/inspect"
1413
appstore "github.com/docker/app/internal/store"
@@ -25,7 +24,6 @@ const inspectExample = `- $ docker app image inspect myapp
2524

2625
type inspectOptions struct {
2726
pretty bool
28-
cliopts.InstallerContextOptions
2927
}
3028

3129
func muteDockerCli(dockerCli command.Cli) func() {
@@ -37,24 +35,23 @@ func muteDockerCli(dockerCli command.Cli) func() {
3735
}
3836
}
3937

40-
func inspectCmd(dockerCli command.Cli) *cobra.Command {
38+
func inspectCmd(dockerCli command.Cli, installerContext *cliopts.InstallerContextOptions) *cobra.Command {
4139
var opts inspectOptions
4240
cmd := &cobra.Command{
4341
Use: "inspect [OPTIONS] APP_IMAGE",
4442
Short: "Display detailed information about an App image",
4543
Example: inspectExample,
4644
Args: cli.ExactArgs(1),
4745
RunE: func(cmd *cobra.Command, args []string) error {
48-
return runInspect(dockerCli, args[0], opts)
46+
return runInspect(dockerCli, args[0], opts, installerContext)
4947
},
5048
}
51-
opts.InstallerContextOptions.AddFlags(cmd.Flags())
5249
cmd.Flags().BoolVar(&opts.pretty, "pretty", false, "Print the information in a human friendly format")
5350

5451
return cmd
5552
}
5653

57-
func runInspect(dockerCli command.Cli, appname string, opts inspectOptions) error {
54+
func runInspect(dockerCli command.Cli, appname string, opts inspectOptions, installerContext *cliopts.InstallerContextOptions) error {
5855
defer muteDockerCli(dockerCli)()
5956
s, err := appstore.NewApplicationStore(config.Dir())
6057
if err != nil {
@@ -81,7 +78,7 @@ func runInspect(dockerCli command.Cli, appname string, opts inspectOptions) erro
8178
}
8279

8380
if _, hasAction := installation.Bundle.Actions[internal.ActionInspectName]; hasAction {
84-
driverImpl, errBuf, err := cnab.SetupDriver(installation, dockerCli, opts.InstallerContextOptions, os.Stdout)
81+
driverImpl, errBuf, err := cnab.SetupDriver(installation, dockerCli, installerContext, os.Stdout)
8582
if err != nil {
8683
return err
8784
}

internal/commands/image/render.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ import (
2323

2424
type renderOptions struct {
2525
cliopts.ParametersOptions
26-
cliopts.InstallerContextOptions
2726
formatDriver string
2827
renderOutput string
2928
}
3029

31-
func renderCmd(dockerCli command.Cli) *cobra.Command {
30+
func renderCmd(dockerCli command.Cli, installerContext *cliopts.InstallerContextOptions) *cobra.Command {
3231
var opts renderOptions
3332
cmd := &cobra.Command{
3433
Use: "render [OPTIONS] APP_IMAGE",
@@ -37,18 +36,17 @@ func renderCmd(dockerCli command.Cli) *cobra.Command {
3736
Args: cli.ExactArgs(1),
3837
Hidden: true,
3938
RunE: func(cmd *cobra.Command, args []string) error {
40-
return runRender(dockerCli, args[0], opts)
39+
return runRender(dockerCli, args[0], opts, installerContext)
4140
},
4241
}
4342
opts.ParametersOptions.AddFlags(cmd.Flags())
44-
opts.InstallerContextOptions.AddFlags(cmd.Flags())
4543
cmd.Flags().StringVarP(&opts.renderOutput, "output", "o", "-", "Output file")
4644
cmd.Flags().StringVar(&opts.formatDriver, "formatter", "yaml", "Configure the output format (yaml|json)")
4745

4846
return cmd
4947
}
5048

51-
func runRender(dockerCli command.Cli, appname string, opts renderOptions) error {
49+
func runRender(dockerCli command.Cli, appname string, opts renderOptions, installerContext *cliopts.InstallerContextOptions) error {
5250
defer muteDockerCli(dockerCli)()
5351

5452
var w io.Writer = os.Stdout
@@ -66,7 +64,7 @@ func runRender(dockerCli command.Cli, appname string, opts renderOptions) error
6664
return nil
6765
}
6866

69-
action, installation, errBuf, err := prepareCustomAction(internal.ActionRenderName, dockerCli, appname, w, opts)
67+
action, installation, errBuf, err := prepareCustomAction(internal.ActionRenderName, dockerCli, appname, w, opts, installerContext)
7068
if err != nil {
7169
return err
7270
}
@@ -78,7 +76,13 @@ func runRender(dockerCli command.Cli, appname string, opts renderOptions) error
7876
return nil
7977
}
8078

81-
func prepareCustomAction(actionName string, dockerCli command.Cli, appname string, stdout io.Writer, opts renderOptions) (*action.RunCustom, *appstore.Installation, *bytes.Buffer, error) {
79+
func prepareCustomAction(actionName string,
80+
dockerCli command.Cli,
81+
appname string,
82+
stdout io.Writer,
83+
opts renderOptions,
84+
installerContext *cliopts.InstallerContextOptions) (*action.RunCustom, *appstore.Installation, *bytes.Buffer, error) {
85+
8286
s, err := appstore.NewApplicationStore(config.Dir())
8387
if err != nil {
8488
return nil, nil, nil, err
@@ -103,7 +107,7 @@ func prepareCustomAction(actionName string, dockerCli command.Cli, appname strin
103107
return nil, nil, nil, err
104108
}
105109

106-
driverImpl, errBuf, err := cnab.SetupDriver(installation, dockerCli, opts.InstallerContextOptions, stdout)
110+
driverImpl, errBuf, err := cnab.SetupDriver(installation, dockerCli, installerContext, stdout)
107111
if err != nil {
108112
return nil, nil, nil, err
109113
}

internal/commands/inspect.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,26 @@ const inspectExample = `- $ docker app inspect my-running-app
2222

2323
type inspectOptions struct {
2424
credentialOptions
25-
cliopts.InstallerContextOptions
2625
pretty bool
2726
}
2827

29-
func inspectCmd(dockerCli command.Cli) *cobra.Command {
28+
func inspectCmd(dockerCli command.Cli, installerContext *cliopts.InstallerContextOptions) *cobra.Command {
3029
var opts inspectOptions
3130
cmd := &cobra.Command{
3231
Use: "inspect [OPTIONS] RUNNING_APP",
3332
Short: "Shows status, metadata, parameters and the list of services of a running App",
3433
Example: inspectExample,
3534
Args: cli.ExactArgs(1),
3635
RunE: func(cmd *cobra.Command, args []string) error {
37-
return runInspect(dockerCli, firstOrEmpty(args), opts)
36+
return runInspect(dockerCli, args[0], opts, installerContext)
3837
},
3938
}
4039
cmd.Flags().BoolVar(&opts.pretty, "pretty", false, "Pretty print the output")
4140
opts.credentialOptions.addFlags(cmd.Flags())
42-
opts.InstallerContextOptions.AddFlags(cmd.Flags())
4341
return cmd
4442
}
4543

46-
func runInspect(dockerCli command.Cli, appName string, inspectOptions inspectOptions) error {
44+
func runInspect(dockerCli command.Cli, appName string, inspectOptions inspectOptions, installerContext *cliopts.InstallerContextOptions) error {
4745
defer muteDockerCli(dockerCli)()
4846
_, installationStore, credentialStore, err := prepareStores(dockerCli.CurrentContext())
4947
if err != nil {
@@ -60,7 +58,7 @@ func runInspect(dockerCli command.Cli, appName string, inspectOptions inspectOpt
6058
}
6159

6260
var buf bytes.Buffer
63-
driverImpl, errBuf, err := cnab.SetupDriver(installation, dockerCli, inspectOptions.InstallerContextOptions, &buf)
61+
driverImpl, errBuf, err := cnab.SetupDriver(installation, dockerCli, installerContext, &buf)
6462
if err != nil {
6563
return err
6664
}

0 commit comments

Comments
 (0)