extract upgrade requirement checkings
This commit is contained in:
@ -333,6 +333,40 @@ func createDeployConfig(recipeName string, stackName string, env config.AppEnv)
|
|||||||
config.SetUpdateLabel(compose, stackName, env)
|
config.SetUpdateLabel(compose, stackName, env)
|
||||||
return compose, deployOpts, nil
|
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
|
// upgrade performs all necessary steps to upgrade an app
|
||||||
@ -381,7 +415,6 @@ func newAbraApp(version, commit string) *cli.App {
|
|||||||
Commands: []cli.Command{
|
Commands: []cli.Command{
|
||||||
Notify,
|
Notify,
|
||||||
UpgradeApp,
|
UpgradeApp,
|
||||||
UpgradeAll,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user