feat: add rollback command
All checks were successful
continuous-integration/drone/push Build is passing

Closes coop-cloud/organising#127.
This commit is contained in:
2021-10-14 01:44:57 +02:00
parent 875255fd8c
commit b69aed3bcf
2 changed files with 119 additions and 38 deletions

View File

@ -20,6 +20,9 @@ var appUpgradeCommand = &cli.Command{
Aliases: []string{"u"},
Usage: "Upgrade an app",
ArgsUsage: "<app>",
Flags: []cli.Flag{
internal.ForceFlag,
},
Description: `
This command supports upgrading an app. You can use it to choose and roll out a
new upgrade to an existing app. This command specifically supports changing the
@ -44,11 +47,11 @@ could be destructive, please ensure you have a copy of your app data beforehand
}
if deployedVersion == "" {
logrus.Fatal("failed to determine version of deployed '%s'", app.Name)
logrus.Fatalf("failed to determine version of deployed '%s'", app.Name)
}
if !isDeployed {
logrus.Fatal("'%s' is not deployed?", app.Name)
logrus.Fatalf("'%s' is not deployed?", app.Name)
}
versions, err := catalogue.GetRecipeCatalogueVersions(app.Type)
@ -76,12 +79,19 @@ could be destructive, please ensure you have a copy of your app data beforehand
}
var chosenUpgrade string
prompt := &survey.Select{
Message: "Please select an upgrade:",
Options: availableUpgrades,
if !internal.Force {
prompt := &survey.Select{
Message: fmt.Sprintf("Please select an upgrade (current version: '%s'):", deployedVersion),
Options: availableUpgrades,
}
if err := survey.AskOne(prompt, &chosenUpgrade); err != nil {
return err
}
}
if err := survey.AskOne(prompt, &chosenUpgrade); err != nil {
return err
if internal.Force {
chosenUpgrade = availableUpgrades[len(availableUpgrades)-1]
logrus.Debugf("choosing '%s' as version to upgrade to", chosenUpgrade)
}
if err := recipe.EnsureVersion(app.Type, chosenUpgrade); err != nil {
@ -112,8 +122,10 @@ could be destructive, please ensure you have a copy of your app data beforehand
logrus.Fatal(err)
}
if err := DeployOverview(app, chosenUpgrade); err != nil {
logrus.Fatal(err)
if !internal.Force {
if err := DeployOverview(app, chosenUpgrade); err != nil {
logrus.Fatal(err)
}
}
if err := stack.RunDeploy(cl, deployOpts, compose); err != nil {