add a label to signal that a deploy is a chaos deploy

This commit is contained in:
Moritz 2023-01-26 13:08:03 +01:00
parent ef3ad1c637
commit af7f0ee391
4 changed files with 15 additions and 0 deletions

View File

@ -179,6 +179,7 @@ recipes.
logrus.Fatal(err)
}
config.ExposeAllEnv(compose, app.Env)
config.SetChaosLabel(compose, stackName, internal.Chaos)
if !internal.Force {
if err := internal.NewVersionOverview(app, deployedVersion, chosenDowngrade, ""); err != nil {

View File

@ -190,6 +190,7 @@ recipes.
logrus.Fatal(err)
}
config.ExposeAllEnv(compose, app.Env)
config.SetChaosLabel(compose, stackName, internal.Chaos)
if err := internal.NewVersionOverview(app, deployedVersion, chosenUpgrade, releaseNotes); err != nil {
logrus.Fatal(err)

View File

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

View File

@ -5,6 +5,7 @@ import (
"io/ioutil"
"os"
"path"
"strconv"
"strings"
"github.com/schollz/progressbar/v3"
@ -461,3 +462,14 @@ func ExposeAllEnv(compose *composetypes.Config, appEnv AppEnv) {
}
}
}
// add a label to signal that a deploy is a chaos deploy
func SetChaosLabel(compose *composetypes.Config, stackName string, chaos bool) {
for _, service := range compose.Services {
if service.Name == "app" {
logrus.Debugf("set chaos label to %s", chaos)
labelKey := fmt.Sprintf("coop-cloud.%s.chaos", stackName)
service.Deploy.Labels[labelKey] = strconv.FormatBool(chaos)
}
}
}