From 23a0b92d88b1489ea0ae46557bb8f5fe783b4006 Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 26 Jan 2023 13:15:31 +0100 Subject: [PATCH 1/2] add a label to signal that a deploy is connected with a recipe --- cli/app/rollback.go | 1 + cli/app/upgrade.go | 1 + cli/internal/deploy.go | 1 + pkg/config/app.go | 11 +++++++++++ 4 files changed, 14 insertions(+) diff --git a/cli/app/rollback.go b/cli/app/rollback.go index 98acf56f..cadd4d47 100644 --- a/cli/app/rollback.go +++ b/cli/app/rollback.go @@ -179,6 +179,7 @@ recipes. logrus.Fatal(err) } config.ExposeAllEnv(stackName, compose, app.Env) + config.SetRecipeLabel(compose, stackName, app.Recipe) 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 fa46b8d3..5037a490 100644 --- a/cli/app/upgrade.go +++ b/cli/app/upgrade.go @@ -190,6 +190,7 @@ recipes. logrus.Fatal(err) } config.ExposeAllEnv(stackName, compose, app.Env) + config.SetRecipeLabel(compose, stackName, app.Recipe) 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 6b3047fb..68a007e5 100644 --- a/cli/internal/deploy.go +++ b/cli/internal/deploy.go @@ -135,6 +135,7 @@ func DeployAction(c *cli.Context) error { logrus.Fatal(err) } config.ExposeAllEnv(app.StackName(), compose, app.Env) + config.SetRecipeLabel(compose, app.StackName(), app.Recipe) 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 15253634..306d5832 100644 --- a/pkg/config/app.go +++ b/pkg/config/app.go @@ -464,3 +464,14 @@ func ExposeAllEnv(stackName string, compose *composetypes.Config, appEnv AppEnv) } } } + +// add a label to signal that a deploy is connected with a recipe +func SetRecipeLabel(compose *composetypes.Config, stackName string, recipe string) { + for _, service := range compose.Services { + if service.Name == "app" { + logrus.Debugf("set recipe label to %s", recipe) + labelKey := fmt.Sprintf("coop-cloud.%s.recipe", stackName) + service.Deploy.Labels[labelKey] = recipe + } + } +} -- 2.47.2 From 5b74a5629451ad51cabe658761bed3b2256678d0 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 31 Jan 2023 15:30:46 +0100 Subject: [PATCH 2/2] resolve PR: include the service info in the log message --- pkg/config/app.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/config/app.go b/pkg/config/app.go index 306d5832..bb06e10d 100644 --- a/pkg/config/app.go +++ b/pkg/config/app.go @@ -465,11 +465,12 @@ func ExposeAllEnv(stackName string, compose *composetypes.Config, appEnv AppEnv) } } -// add a label to signal that a deploy is connected with a recipe +// SetRecipeLabel adds the label 'coop-cloud.${STACK_NAME}.recipe=${RECIPE}' to the app container +// to signal which recipe is connected to the deployed app func SetRecipeLabel(compose *composetypes.Config, stackName string, recipe string) { for _, service := range compose.Services { if service.Name == "app" { - logrus.Debugf("set recipe label to %s", recipe) + logrus.Debugf("set recipe label 'coop-cloud.%s.recipe' to %s for %s", stackName, recipe, stackName) labelKey := fmt.Sprintf("coop-cloud.%s.recipe", stackName) service.Deploy.Labels[labelKey] = recipe } -- 2.47.2