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

Commit fc64d21

Browse files
Merge pull request #681 from ndeloof/run
Align docker app with `docker run` UX
2 parents 35fdf49 + f0cd91c commit fc64d21

File tree

7 files changed

+29
-35
lines changed

7 files changed

+29
-35
lines changed

e2e/cnab_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func TestCallCustomStatusAction(t *testing.T) {
5050
icmd.RunCmd(cmd).Assert(t, icmd.Success)
5151

5252
// docker app install
53-
cmd.Command = dockerCli.Command("app", "install", path.Join(testDir, "bundle.json"), "--name", testCase.name)
53+
cmd.Command = dockerCli.Command("app", "run", path.Join(testDir, "bundle.json"), "--name", testCase.name)
5454
icmd.RunCmd(cmd).Assert(t, icmd.Success)
5555

5656
// docker app uninstall
@@ -78,7 +78,7 @@ func TestCnabParameters(t *testing.T) {
7878
}()
7979

8080
// docker app install
81-
cmd.Command = dockerCli.Command("app", "install", path.Join(testDir, "bundle.json"), "--name", "cnab-parameters",
81+
cmd.Command = dockerCli.Command("app", "run", path.Join(testDir, "bundle.json"), "--name", "cnab-parameters",
8282
"--set", "boolParam=true",
8383
"--set", "stringParam=value",
8484
"--set", "intParam=42",

e2e/commands_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func testDockerAppLifecycle(t *testing.T, useBindMount bool) {
198198
initializeDockerAppEnvironment(t, &cmd, tmpDir, swarm, useBindMount)
199199

200200
// Install an illformed Docker Application Package
201-
cmd.Command = dockerCli.Command("app", "install", "testdata/simple/simple.dockerapp", "--set", "web_port=-1", "--name", appName)
201+
cmd.Command = dockerCli.Command("app", "run", "testdata/simple/simple.dockerapp", "--set", "web_port=-1", "--name", appName)
202202
icmd.RunCmd(cmd).Assert(t, icmd.Expected{
203203
ExitCode: 1,
204204
Err: "error decoding 'Ports': Invalid hostPort: -1",
@@ -220,7 +220,7 @@ func testDockerAppLifecycle(t *testing.T, useBindMount bool) {
220220
})
221221

222222
// Install a Docker Application Package with an existing failed installation is fine
223-
cmd.Command = dockerCli.Command("app", "install", "testdata/simple/simple.dockerapp", "--name", appName)
223+
cmd.Command = dockerCli.Command("app", "run", "testdata/simple/simple.dockerapp", "--name", appName)
224224
checkContains(t, icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(),
225225
[]string{
226226
fmt.Sprintf("WARNING: installing over previously failed installation %q", appName),
@@ -240,7 +240,7 @@ func testDockerAppLifecycle(t *testing.T, useBindMount bool) {
240240
})
241241

242242
// Installing again the same application is forbidden
243-
cmd.Command = dockerCli.Command("app", "install", "testdata/simple/simple.dockerapp", "--name", appName)
243+
cmd.Command = dockerCli.Command("app", "run", "testdata/simple/simple.dockerapp", "--name", appName)
244244
icmd.RunCmd(cmd).Assert(t, icmd.Expected{
245245
ExitCode: 1,
246246
Err: fmt.Sprintf("Installation %q already exists, use 'docker app upgrade' instead", appName),
@@ -307,7 +307,7 @@ func TestCredentials(t *testing.T) {
307307

308308
t.Run("missing", func(t *testing.T) {
309309
cmd.Command = dockerCli.Command(
310-
"app", "install",
310+
"app", "run",
311311
"--credential", "secret1=foo",
312312
// secret2 deliberately omitted.
313313
"--credential", "secret3=baz",
@@ -322,7 +322,7 @@ func TestCredentials(t *testing.T) {
322322

323323
t.Run("full", func(t *testing.T) {
324324
cmd.Command = dockerCli.Command(
325-
"app", "install",
325+
"app", "run",
326326
"--credential", "secret1=foo",
327327
"--credential", "secret2=bar",
328328
"--credential", "secret3=baz",
@@ -334,7 +334,7 @@ func TestCredentials(t *testing.T) {
334334

335335
t.Run("mixed-credstore", func(t *testing.T) {
336336
cmd.Command = dockerCli.Command(
337-
"app", "install",
337+
"app", "run",
338338
"--credential-set", "test-creds",
339339
"--credential", "secret3=xyzzy",
340340
"--name", "mixed-credstore", bundle,
@@ -345,7 +345,7 @@ func TestCredentials(t *testing.T) {
345345

346346
t.Run("mixed-local-cred", func(t *testing.T) {
347347
cmd.Command = dockerCli.Command(
348-
"app", "install",
348+
"app", "run",
349349
"--credential-set", tmpDir.Join("local", "test-creds.yaml"),
350350
"--credential", "secret3=xyzzy",
351351
"--name", "mixed-local-cred", bundle,
@@ -356,7 +356,7 @@ func TestCredentials(t *testing.T) {
356356

357357
t.Run("overload", func(t *testing.T) {
358358
cmd.Command = dockerCli.Command(
359-
"app", "install",
359+
"app", "run",
360360
"--credential-set", "test-creds",
361361
"--credential", "secret1=overload",
362362
"--credential", "secret3=xyzzy",

e2e/pushpull_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func TestPushInstall(t *testing.T) {
144144
cmd.Command = dockerCli.Command("app", "push", "--tag", ref, filepath.Join("testdata", "push-pull", "push-pull.dockerapp"))
145145
icmd.RunCmd(cmd).Assert(t, icmd.Success)
146146

147-
cmd.Command = dockerCli.Command("app", "install", ref, "--name", t.Name())
147+
cmd.Command = dockerCli.Command("app", "run", ref, "--name", t.Name())
148148
icmd.RunCmd(cmd).Assert(t, icmd.Success)
149149
cmd.Command = dockerCli.Command("service", "ls")
150150
assert.Check(t, cmp.Contains(icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(), ref))
@@ -165,7 +165,7 @@ func TestPushPullInstall(t *testing.T) {
165165
info.stopRegistry()
166166

167167
// install from local store
168-
cmd.Command = dockerCli.Command("app", "install", ref+tag, "--name", t.Name())
168+
cmd.Command = dockerCli.Command("app", "run", ref+tag, "--name", t.Name())
169169
icmd.RunCmd(cmd).Assert(t, icmd.Success)
170170
cmd.Command = dockerCli.Command("service", "ls")
171171
assert.Check(t, cmp.Contains(icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(), ref))
@@ -178,7 +178,7 @@ func TestPushPullInstall(t *testing.T) {
178178
})
179179

180180
// install should fail (registry is stopped)
181-
cmd.Command = dockerCli.Command("app", "install", "unknown")
181+
cmd.Command = dockerCli.Command("app", "run", "unknown")
182182
//nolint: lll
183183
expected := `Unable to find application image "unknown:latest" locally
184184
Unable to find application "unknown": failed to resolve bundle manifest "docker.io/library/unknown:latest": pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed`
@@ -205,7 +205,7 @@ func TestPushInstallBundle(t *testing.T) {
205205
cmd.Command = dockerCli.Command("app", "push", "--tag", ref, "a-simple-app:1.0.0")
206206
icmd.RunCmd(cmd).Assert(t, icmd.Success)
207207

208-
cmd.Command = dockerCli.Command("app", "install", ref, "--name", name)
208+
cmd.Command = dockerCli.Command("app", "run", ref, "--name", name)
209209
icmd.RunCmd(cmd).Assert(t, icmd.Success)
210210
cmd.Command = dockerCli.Command("service", "ls")
211211
assert.Check(t, cmp.Contains(icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(), ref))
@@ -225,7 +225,7 @@ func TestPushInstallBundle(t *testing.T) {
225225
cmd.Command = dockerCli.Command("app", "push", "--tag", ref2, ref+":latest")
226226
icmd.RunCmd(cmd).Assert(t, icmd.Success)
227227

228-
cmd.Command = dockerCli.Command("app", "install", ref2, "--name", name)
228+
cmd.Command = dockerCli.Command("app", "run", ref2, "--name", name)
229229
icmd.RunCmd(cmd).Assert(t, icmd.Success)
230230
cmd.Command = dockerCli.Command("service", "ls")
231231
assert.Check(t, cmp.Contains(icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(), ref2))
@@ -252,7 +252,7 @@ func TestPushInstallBundle(t *testing.T) {
252252
// remove the bundle from the bundle store to be sure it won't be used instead of registry
253253
cleanupIsolatedStore()
254254
// install from the registry
255-
cmd.Command = dockerCli.Command("app", "install", ref2, "--name", name)
255+
cmd.Command = dockerCli.Command("app", "run", ref2, "--name", name)
256256
icmd.RunCmd(cmd).Assert(t, icmd.Success)
257257
cmd.Command = dockerCli.Command("service", "ls")
258258
assert.Check(t, cmp.Contains(icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(), ref))

e2e/testdata/plugin-usage-experimental.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ Commands:
1313
build Build service images for the application
1414
init Initialize Docker Application definition
1515
inspect Shows metadata, parameters and a summary of the Compose file for a given application
16-
install Install an application
1716
ls List the installations and their last known installation result
1817
pull Pull an application package from a registry
1918
push Push an application package to a registry
2019
rm Remove an application
20+
run Run an application
2121
upgrade Upgrade an installed application
2222
validate Checks the rendered application is syntactically correct
2323

e2e/testdata/plugin-usage.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ Commands:
1313
build Build service images for the application
1414
init Initialize Docker Application definition
1515
inspect Shows metadata, parameters and a summary of the Compose file for a given application
16-
install Install an application
1716
ls List the installations and their last known installation result
1817
pull Pull an application package from a registry
1918
push Push an application package to a registry
2019
rm Remove an application
20+
run Run an application
2121
upgrade Upgrade an installed application
2222
validate Checks the rendered application is syntactically correct
2323

internal/commands/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func NewRootCmd(use string, dockerCli command.Cli) *cobra.Command {
4949

5050
func addCommands(cmd *cobra.Command, dockerCli command.Cli) {
5151
cmd.AddCommand(
52-
installCmd(dockerCli),
52+
runCmd(dockerCli),
5353
upgradeCmd(dockerCli),
5454
removeCmd(dockerCli),
5555
listCmd(dockerCli),

internal/commands/install.go renamed to internal/commands/run.go

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"github.com/spf13/cobra"
1616
)
1717

18-
type installOptions struct {
18+
type runOptions struct {
1919
parametersOptions
2020
credentialOptions
2121
orchestrator string
@@ -33,28 +33,22 @@ const (
3333
nameKindReference
3434
)
3535

36-
const longDescription = `Install an application.
37-
By default, the application definition in the current directory will be
38-
installed. The APP_NAME can also be:
39-
- a path to a Docker Application definition (.dockerapp) or a CNAB bundle.json
40-
- a registry Application Package reference`
36+
const longDescription = `Run an application based on a docker app image.`
4137

42-
const example = `$ docker app install myapp.dockerapp --name myinstallation --target-context=mycontext
43-
$ docker app install myrepo/myapp:mytag --name myinstallation --target-context=mycontext
44-
$ docker app install bundle.json --name myinstallation --credential-set=mycredentials.yml`
38+
const example = `$ docker app run --name myinstallation --target-context=mycontext myrepo/myapp:mytag`
4539

46-
func installCmd(dockerCli command.Cli) *cobra.Command {
47-
var opts installOptions
40+
func runCmd(dockerCli command.Cli) *cobra.Command {
41+
var opts runOptions
4842

4943
cmd := &cobra.Command{
50-
Use: "install [APP_NAME] [--name INSTALLATION_NAME] [--target-context TARGET_CONTEXT] [OPTIONS]",
44+
Use: "run [OPTIONS] [APP_IMAGE]",
5145
Aliases: []string{"deploy"},
52-
Short: "Install an application",
46+
Short: "Run an application",
5347
Long: longDescription,
5448
Example: example,
55-
Args: cli.RequiresMaxArgs(1),
49+
Args: cli.ExactArgs(1),
5650
RunE: func(cmd *cobra.Command, args []string) error {
57-
return runInstall(dockerCli, firstOrEmpty(args), opts)
51+
return runRun(dockerCli, args[0], opts)
5852
},
5953
}
6054
opts.parametersOptions.addFlags(cmd.Flags())
@@ -66,7 +60,7 @@ func installCmd(dockerCli command.Cli) *cobra.Command {
6660
return cmd
6761
}
6862

69-
func runInstall(dockerCli command.Cli, appname string, opts installOptions) error {
63+
func runRun(dockerCli command.Cli, appname string, opts runOptions) error {
7064
opts.SetDefaultTargetContext(dockerCli)
7165

7266
bind, err := requiredBindMount(opts.targetContext, opts.orchestrator, dockerCli.ContextStore())

0 commit comments

Comments
 (0)