From 23a0b92d88b1489ea0ae46557bb8f5fe783b4006 Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 26 Jan 2023 13:15:31 +0100 Subject: [PATCH] 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 + } + } +}