From 6774893412b3f2ea03d1c592dc4e7d2251329b70 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 31 Jan 2023 13:33:41 +0100 Subject: [PATCH 1/2] add env ENABLE_AUTO_UPDATE as label to enable/disable the auto update process --- cli/app/rollback.go | 1 + cli/app/upgrade.go | 1 + cli/internal/deploy.go | 1 + pkg/config/app.go | 15 +++++++++++++++ 4 files changed, 18 insertions(+) diff --git a/cli/app/rollback.go b/cli/app/rollback.go index 941b2fcd..c848a235 100644 --- a/cli/app/rollback.go +++ b/cli/app/rollback.go @@ -181,6 +181,7 @@ recipes. config.ExposeAllEnv(stackName, compose, app.Env) config.SetRecipeLabel(compose, stackName, app.Recipe) config.SetChaosLabel(compose, stackName, internal.Chaos) + config.SetUpdateLabel(compose, stackName, app.Env) if !internal.Force { if err := internal.NewVersionOverview(app, deployedVersion, chosenDowngrade, ""); err != nil { diff --git a/cli/app/upgrade.go b/cli/app/upgrade.go index a2138f27..ceca4966 100644 --- a/cli/app/upgrade.go +++ b/cli/app/upgrade.go @@ -192,6 +192,7 @@ recipes. config.ExposeAllEnv(stackName, compose, app.Env) config.SetRecipeLabel(compose, stackName, app.Recipe) config.SetChaosLabel(compose, stackName, internal.Chaos) + config.SetUpdateLabel(compose, stackName, app.Env) if err := internal.NewVersionOverview(app, deployedVersion, chosenUpgrade, releaseNotes); err != nil { logrus.Fatal(err) diff --git a/cli/internal/deploy.go b/cli/internal/deploy.go index 3ae9d8e0..0a0369a5 100644 --- a/cli/internal/deploy.go +++ b/cli/internal/deploy.go @@ -137,6 +137,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.SetUpdateLabel(compose, app.StackName(), app.Env) if err := DeployOverview(app, version, "continue with deployment?"); err != nil { logrus.Fatal(err) diff --git a/pkg/config/app.go b/pkg/config/app.go index 64de339d..ab35de39 100644 --- a/pkg/config/app.go +++ b/pkg/config/app.go @@ -489,3 +489,18 @@ func SetChaosLabel(compose *composetypes.Config, stackName string, chaos bool) { } } } + +// add env ENABLE_AUTO_UPDATE as label to enable/disable the auto update process for this app +func SetUpdateLabel(compose *composetypes.Config, stackName string, appEnv AppEnv) { + for _, service := range compose.Services { + if service.Name == "app" { + enable_auto_update, exists := appEnv["ENABLE_AUTO_UPDATE"] + if !exists { + enable_auto_update = "false" + } + logrus.Debugf("set auto update label to %s", enable_auto_update) + labelKey := fmt.Sprintf("coop-cloud.%s.autoupdate", stackName) + service.Deploy.Labels[labelKey] = enable_auto_update + } + } +} -- 2.49.0 From 76717531bd6040a7144f71201a14a99a7594828d Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 31 Jan 2023 16:15:11 +0100 Subject: [PATCH 2/2] resolve PR: include the service info in the log message --- pkg/config/app.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/config/app.go b/pkg/config/app.go index ab35de39..28f43830 100644 --- a/pkg/config/app.go +++ b/pkg/config/app.go @@ -490,7 +490,9 @@ func SetChaosLabel(compose *composetypes.Config, stackName string, chaos bool) { } } -// add env ENABLE_AUTO_UPDATE as label to enable/disable the auto update process for this app +// 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. func SetUpdateLabel(compose *composetypes.Config, stackName string, appEnv AppEnv) { for _, service := range compose.Services { if service.Name == "app" { @@ -498,7 +500,7 @@ func SetUpdateLabel(compose *composetypes.Config, stackName string, appEnv AppEn if !exists { enable_auto_update = "false" } - logrus.Debugf("set auto update label to %s", enable_auto_update) + logrus.Debugf("set label 'coop-cloud.%s.autoupdate' to %s for %s", stackName, enable_auto_update, stackName) labelKey := fmt.Sprintf("coop-cloud.%s.autoupdate", stackName) service.Deploy.Labels[labelKey] = enable_auto_update } -- 2.49.0