Set chaos version label for each deployed or upgraded app

This commit is contained in:
Moritz 2023-03-01 12:16:17 +01:00
parent f29278f80a
commit 611430aab2
4 changed files with 14 additions and 0 deletions

View File

@ -183,6 +183,7 @@ recipes.
config.ExposeAllEnv(stackName, compose, app.Env)
config.SetRecipeLabel(compose, stackName, app.Recipe)
config.SetChaosLabel(compose, stackName, internal.Chaos)
config.SetChaosVersionLabel(compose, app.StackName(), chosenDowngrade)
config.SetUpdateLabel(compose, stackName, app.Env)
if !internal.Force {

View File

@ -194,6 +194,7 @@ recipes.
config.ExposeAllEnv(stackName, compose, app.Env)
config.SetRecipeLabel(compose, stackName, app.Recipe)
config.SetChaosLabel(compose, stackName, internal.Chaos)
config.SetChaosVersionLabel(compose, app.StackName(), chosenUpgrade)
config.SetUpdateLabel(compose, stackName, app.Env)
if err := internal.NewVersionOverview(app, deployedVersion, chosenUpgrade, releaseNotes); err != nil {

View File

@ -139,6 +139,7 @@ func DeployAction(c *cli.Context) error {
config.ExposeAllEnv(app.StackName(), compose, app.Env)
config.SetRecipeLabel(compose, app.StackName(), app.Recipe)
config.SetChaosLabel(compose, app.StackName(), Chaos)
config.SetChaosVersionLabel(compose, app.StackName(), version)
config.SetUpdateLabel(compose, app.StackName(), app.Env)
if err := DeployOverview(app, version, "continue with deployment?"); err != nil {

View File

@ -499,6 +499,17 @@ func SetChaosLabel(compose *composetypes.Config, stackName string, chaos bool) {
}
}
// SetChaosVersionLabel adds the label 'coop-cloud.${STACK_NAME}.chaos_version=$(GIT_COMMIT)' to the app container
func SetChaosVersionLabel(compose *composetypes.Config, stackName string, chaosVersion string) {
for _, service := range compose.Services {
if service.Name == "app" {
logrus.Debugf("set label 'coop-cloud.%s.chaos_version' to %v for %s", stackName, chaosVersion, stackName)
labelKey := fmt.Sprintf("coop-cloud.%s.chaos_version", stackName)
service.Deploy.Labels[labelKey] = chaosVersion
}
}
}
// SetUpdateLabel adds env ENABLE_AUTO_UPDATE as label to enable/disable the
// auto update process for this app. The default if this variable is not set is to disable
// the auto update process.