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

Commit

Permalink
Merge pull request #694 from rumpl/ux-upgrade-update
Browse files Browse the repository at this point in the history
Rename upgrade to update
  • Loading branch information
chris-crone authored Oct 16, 2019
2 parents b9f8d49 + 32da7d2 commit 8f1a594
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ Commands:
pull Pull an application package from a registry
push Push an application package to a registry
rm Remove an application
upgrade Upgrade an installed application
update Update a running application
validate Checks the rendered application is syntactically correct

Run 'docker app COMMAND --help' for more information on a command.
Expand Down
10 changes: 5 additions & 5 deletions e2e/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ func testDockerAppLifecycle(t *testing.T, useBindMount bool) {
})

// Upgrading a failed installation is not allowed
cmd.Command = dockerCli.Command("app", "upgrade", appName)
cmd.Command = dockerCli.Command("app", "update", appName)
icmd.RunCmd(cmd).Assert(t, icmd.Expected{
ExitCode: 1,
Err: fmt.Sprintf("Installation %q has failed and cannot be upgraded, reinstall it using 'docker app install'", appName),
Err: fmt.Sprintf("Installation %q has failed and cannot be updated, reinstall it using 'docker app install'", appName),
})

// Install a Docker Application Package with an existing failed installation is fine
Expand Down Expand Up @@ -244,11 +244,11 @@ func testDockerAppLifecycle(t *testing.T, useBindMount bool) {
cmd.Command = dockerCli.Command("app", "run", "testdata/simple/simple.dockerapp", "--name", appName)
icmd.RunCmd(cmd).Assert(t, icmd.Expected{
ExitCode: 1,
Err: fmt.Sprintf("Installation %q already exists, use 'docker app upgrade' instead", appName),
Err: fmt.Sprintf("Installation %q already exists, use 'docker app update' instead", appName),
})

// Upgrade the application, changing the port
cmd.Command = dockerCli.Command("app", "upgrade", appName, "--set", "web_port=8081")
// Update the application, changing the port
cmd.Command = dockerCli.Command("app", "update", appName, "--set", "web_port=8081")
checkContains(t, icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(),
[]string{
fmt.Sprintf("Updating service %s_db", appName),
Expand Down
2 changes: 1 addition & 1 deletion e2e/testdata/plugin-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Commands:
push Push an application package to a registry
rm Remove an application
run Run an application
upgrade Upgrade an installed application
update Update a running application
validate Checks the rendered application is syntactically correct

Run 'docker app COMMAND --help' for more information on a command.
4 changes: 2 additions & 2 deletions examples/cnab-simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ Install the application:
$ docker app install
```

Upgrade the installation, demonstrating setting parameters:
Update the installation, demonstrating setting parameters:

```console
$ docker app upgrade --set port=9876 --set text="hello DockerCon EU" hello
$ docker app update --set port=9876 --set text="hello DockerCon EU" hello
```

Uninstall the application installation:
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewRootCmd(use string, dockerCli command.Cli) *cobra.Command {
func addCommands(cmd *cobra.Command, dockerCli command.Cli) {
cmd.AddCommand(
runCmd(dockerCli),
upgradeCmd(dockerCli),
updateCmd(dockerCli),
removeCmd(dockerCli),
listCmd(dockerCli),
initCmd(dockerCli),
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func runRun(dockerCli command.Cli, appname string, opts runOptions) error {
} else {
// Return an error in case of successful installation, or even failed upgrade, which means
// their was already a successful installation.
return fmt.Errorf("Installation %q already exists, use 'docker app upgrade' instead", installationName)
return fmt.Errorf("Installation %q already exists, use 'docker app update' instead", installationName)
}
} else {
logrus.Debug(err)
Expand Down
24 changes: 12 additions & 12 deletions internal/commands/upgrade.go → internal/commands/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ import (
"github.com/spf13/cobra"
)

type upgradeOptions struct {
type updateOptions struct {
parametersOptions
credentialOptions
bundleOrDockerApp string
}

func upgradeCmd(dockerCli command.Cli) *cobra.Command {
var opts upgradeOptions
func updateCmd(dockerCli command.Cli) *cobra.Command {
var opts updateOptions
cmd := &cobra.Command{
Use: "upgrade INSTALLATION_NAME [--target-context TARGET_CONTEXT] [OPTIONS]",
Short: "Upgrade an installed application",
Example: `$ docker app upgrade myinstallation --target-context=mycontext --set key=value`,
Use: "update [OPTIONS] RUNNING_APP",
Short: "Update a running application",
Example: `$ docker app update myrunningapp --target-context=mycontext --set key=value`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
return runUpgrade(dockerCli, args[0], opts)
return runUpdate(dockerCli, args[0], opts)
},
}
opts.parametersOptions.addFlags(cmd.Flags())
opts.credentialOptions.addFlags(cmd.Flags())
cmd.Flags().StringVar(&opts.bundleOrDockerApp, "app-name", "", "Override the installation with another Application Package")
cmd.Flags().StringVar(&opts.bundleOrDockerApp, "image", "", "Override the installation with another Application Package")

return cmd
}

func runUpgrade(dockerCli command.Cli, installationName string, opts upgradeOptions) error {
func runUpdate(dockerCli command.Cli, installationName string, opts updateOptions) error {
defer muteDockerCli(dockerCli)()
opts.SetDefaultTargetContext(dockerCli)

Expand All @@ -49,7 +49,7 @@ func runUpgrade(dockerCli command.Cli, installationName string, opts upgradeOpti
}

if isInstallationFailed(installation) {
return fmt.Errorf("Installation %q has failed and cannot be upgraded, reinstall it using 'docker app install'", installationName)
return fmt.Errorf("Installation %q has failed and cannot be updated, reinstall it using 'docker app install'", installationName)
}

if opts.bundleOrDockerApp != "" {
Expand Down Expand Up @@ -85,11 +85,11 @@ func runUpgrade(dockerCli command.Cli, installationName string, opts upgradeOpti
err = u.Run(&installation.Claim, creds, os.Stdout)
err2 := installationStore.Store(installation)
if err != nil {
return fmt.Errorf("Upgrade failed: %s\n%s", err, errBuf)
return fmt.Errorf("Update failed: %s\n%s", err, errBuf)
}
if err2 != nil {
return err2
}
fmt.Fprintf(os.Stdout, "Application %q upgraded on context %q\n", installationName, opts.targetContext)
fmt.Fprintf(os.Stdout, "Application %q updated on context %q\n", installationName, opts.targetContext)
return nil
}

0 comments on commit 8f1a594

Please sign in to comment.