diff --git a/cli/updater/updater.go b/cli/updater/updater.go index c9798f6d..1dce0c70 100644 --- a/cli/updater/updater.go +++ b/cli/updater/updater.go @@ -333,6 +333,40 @@ func createDeployConfig(recipeName string, stackName string, env config.AppEnv) config.SetUpdateLabel(compose, stackName, env) return compose, deployOpts, nil } + +// tryUpgrade performs the upgrade if all the requirements are fulfilled +func tryUpgrade(cl *dockerclient.Client, stackName string, recipeName string) error { + if recipeName == "" { + logrus.Debugf("Don't update %s due to missing recipe name", stackName) + return nil + } + chaos, err := getBoolLabel(cl, stackName, "chaos") + if err != nil { + return err + } + if chaos && !internal.Chaos { + logrus.Debugf("Don't update %s due to chaos deployment.", stackName) + return nil + } + updatesEnabled, err := getBoolLabel(cl, stackName, "autoupdate") + if err != nil { + return err + } + if !updatesEnabled { + logrus.Debugf("Don't update %s due to disabling auto updates or missing ENABLE_AUTOUPDATE env.", stackName) + return nil + } + upgradeVersion, err := getLatestUpgrade(cl, stackName, recipeName) + if err != nil { + return err + } + if upgradeVersion == "" { + logrus.Debugf("Don't update %s due to no new version.", stackName) + return nil + } + err = upgrade(cl, stackName, recipeName, upgradeVersion) + return err + } // upgrade performs all necessary steps to upgrade an app @@ -381,7 +415,6 @@ func newAbraApp(version, commit string) *cli.App { Commands: []cli.Command{ Notify, UpgradeApp, - UpgradeAll, }, }