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

Commit 38753b7

Browse files
committed
Align docker app with docker run UX
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 6a9e04b commit 38753b7

File tree

7 files changed

+31
-32
lines changed

7 files changed

+31
-32
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`
@@ -204,7 +204,7 @@ func TestPushInstallBundle(t *testing.T) {
204204
cmd.Command = dockerCli.Command("app", "push", "--tag", ref, "a-simple-app:1.0.0")
205205
icmd.RunCmd(cmd).Assert(t, icmd.Success)
206206

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

227-
cmd.Command = dockerCli.Command("app", "install", ref2, "--name", name)
227+
cmd.Command = dockerCli.Command("app", "run", ref2, "--name", name)
228228
icmd.RunCmd(cmd).Assert(t, icmd.Success)
229229
cmd.Command = dockerCli.Command("service", "ls")
230230
assert.Check(t, cmp.Contains(icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(), ref2))
@@ -251,7 +251,7 @@ func TestPushInstallBundle(t *testing.T) {
251251
// remove the bundle from the bundle store to be sure it won't be used instead of registry
252252
cleanupIsolatedStore()
253253
// install from the registry
254-
cmd.Command = dockerCli.Command("app", "install", ref2, "--name", name)
254+
cmd.Command = dockerCli.Command("app", "run", ref2, "--name", name)
255255
icmd.RunCmd(cmd).Assert(t, icmd.Success)
256256
cmd.Command = dockerCli.Command("service", "ls")
257257
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: 12 additions & 13 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,27 @@ 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:
36+
const longDescription = `Run an application.
37+
By default, the application definition in the current directory will be ran. The APP_NAME can also be:
3938
- a path to a Docker Application definition (.dockerapp) or a CNAB bundle.json
4039
- a registry Application Package reference`
4140

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`
41+
const example = `$ docker app run myapp.dockerapp --name myinstallation --target-context=mycontext
42+
$ docker app run myrepo/myapp:mytag --name myinstallation --target-context=mycontext
43+
$ docker app run bundle.json --name myinstallation --credential-set=mycredentials.yml`
4544

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

4948
cmd := &cobra.Command{
50-
Use: "install [APP_NAME] [--name INSTALLATION_NAME] [--target-context TARGET_CONTEXT] [OPTIONS]",
49+
Use: "run [APP_NAME] [--name INSTALLATION_NAME] [--target-context TARGET_CONTEXT] [OPTIONS]",
5150
Aliases: []string{"deploy"},
52-
Short: "Install an application",
51+
Short: "Run an application",
5352
Long: longDescription,
5453
Example: example,
5554
Args: cli.RequiresMaxArgs(1),
5655
RunE: func(cmd *cobra.Command, args []string) error {
57-
return runInstall(dockerCli, firstOrEmpty(args), opts)
56+
return runRun(dockerCli, firstOrEmpty(args), opts)
5857
},
5958
}
6059
opts.parametersOptions.addFlags(cmd.Flags())
@@ -66,7 +65,7 @@ func installCmd(dockerCli command.Cli) *cobra.Command {
6665
return cmd
6766
}
6867

69-
func runInstall(dockerCli command.Cli, appname string, opts installOptions) error {
68+
func runRun(dockerCli command.Cli, appname string, opts runOptions) error {
7069
opts.SetDefaultTargetContext(dockerCli)
7170

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

0 commit comments

Comments
 (0)