forked from coop-cloud/abra
Compare commits
15 Commits
72c807e31a
...
74fd954ac4
Author | SHA1 | Date |
---|---|---|
Moritz | 74fd954ac4 | |
Moritz | b00494b888 | |
Moritz | 68df16bdae | |
Moritz | acd60197f1 | |
Moritz | de77ac55fe | |
Moritz | 1322b2636d | |
Moritz | f271c05332 | |
Moritz | 97a5796d79 | |
Moritz | 45245f8dbb | |
Moritz | 48f52c775f | |
Moritz | 7ce5302f34 | |
Moritz | 817ca09afe | |
Moritz | b8a40adc8f | |
Moritz | 8140b9f352 | |
Moritz | 79fd23695e |
|
@ -178,10 +178,10 @@ recipes.
|
|||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
config.ExposeAllEnv(stackName, compose, app.Env)
|
||||
config.SetRecipeLabel(compose, stackName, app.Recipe)
|
||||
config.SetChaosLabel(compose, stackName, internal.Chaos)
|
||||
config.SetUpdateLabel(compose, stackName, app.Env)
|
||||
config.ExposeAllEnv(compose, app.Env)
|
||||
config.SetChaosLabel(compose, stackName, internal.Chaos)
|
||||
config.SetRecipeLabel(compose, stackName, app.Recipe)
|
||||
|
||||
if !internal.Force {
|
||||
if err := internal.NewVersionOverview(app, deployedVersion, chosenDowngrade, ""); err != nil {
|
||||
|
|
|
@ -189,10 +189,10 @@ recipes.
|
|||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
config.ExposeAllEnv(stackName, compose, app.Env)
|
||||
config.SetRecipeLabel(compose, stackName, app.Recipe)
|
||||
config.SetChaosLabel(compose, stackName, internal.Chaos)
|
||||
config.SetUpdateLabel(compose, stackName, app.Env)
|
||||
config.ExposeAllEnv(compose, app.Env)
|
||||
config.SetChaosLabel(compose, stackName, internal.Chaos)
|
||||
config.SetRecipeLabel(compose, stackName, app.Recipe)
|
||||
|
||||
if err := internal.NewVersionOverview(app, deployedVersion, chosenUpgrade, releaseNotes); err != nil {
|
||||
logrus.Fatal(err)
|
||||
|
|
|
@ -134,10 +134,10 @@ func DeployAction(c *cli.Context) error {
|
|||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
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)
|
||||
config.ExposeAllEnv(compose, app.Env)
|
||||
config.SetChaosLabel(compose, app.StackName(), Chaos)
|
||||
config.SetRecipeLabel(compose, app.StackName(), app.Recipe)
|
||||
|
||||
if err := DeployOverview(app, version, "continue with deployment?"); err != nil {
|
||||
logrus.Fatal(err)
|
||||
|
|
|
@ -140,7 +140,7 @@ func getEnv(cl *dockerclient.Client, stackName string) config.AppEnv {
|
|||
}
|
||||
k := splitString[0]
|
||||
v := splitString[1]
|
||||
logrus.Debugf("Env Key: %s Value: %s", k, v)
|
||||
//logrus.Debugf("Env Key: %s Value: %s", k, v)
|
||||
envMap[k] = v
|
||||
}
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ func createDeployConfig(recipeName string, stackName string, env config.AppEnv)
|
|||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
config.ExposeAllEnv(stackName, compose, env)
|
||||
config.ExposeAllEnv(compose, env)
|
||||
// after the upgrade the deployment won't be in chaos state anymore
|
||||
config.SetChaosLabel(compose, stackName, false)
|
||||
config.SetRecipeLabel(compose, stackName, recipeName)
|
||||
|
|
|
@ -449,50 +449,7 @@ func GetAppComposeConfig(recipe string, opts stack.Deploy, appEnv AppEnv) (*comp
|
|||
return compose, nil
|
||||
}
|
||||
|
||||
// ExposeAllEnv exposes all env variables to the app container
|
||||
func ExposeAllEnv(stackName string, compose *composetypes.Config, appEnv AppEnv) {
|
||||
for _, service := range compose.Services {
|
||||
if service.Name == "app" {
|
||||
logrus.Debugf("Add the following environment to the app service config of %s:", stackName)
|
||||
for k, v := range appEnv {
|
||||
_, exists := service.Environment[k]
|
||||
if !exists {
|
||||
value := v
|
||||
service.Environment[k] = &value
|
||||
logrus.Debugf("Add Key: %s Value: %s to %s", k, value, stackName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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 'coop-cloud.%s.recipe' to %s for %s", stackName, recipe, stackName)
|
||||
labelKey := fmt.Sprintf("coop-cloud.%s.recipe", stackName)
|
||||
service.Deploy.Labels[labelKey] = recipe
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SetChaosLabel adds the label 'coop-cloud.${STACK_NAME}.chaos=true/false' to the app container
|
||||
// to signal if the app is deployed in chaos mode
|
||||
func SetChaosLabel(compose *composetypes.Config, stackName string, chaos bool) {
|
||||
for _, service := range compose.Services {
|
||||
if service.Name == "app" {
|
||||
logrus.Debugf("set label 'coop-cloud.%s.chaos' to %s for %s", stackName, chaos, stackName)
|
||||
labelKey := fmt.Sprintf("coop-cloud.%s.chaos", stackName)
|
||||
service.Deploy.Labels[labelKey] = strconv.FormatBool(chaos)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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.
|
||||
// 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" {
|
||||
|
@ -500,9 +457,48 @@ func SetUpdateLabel(compose *composetypes.Config, stackName string, appEnv AppEn
|
|||
if !exists {
|
||||
enable_auto_update = "false"
|
||||
}
|
||||
logrus.Debugf("set label 'coop-cloud.%s.autoupdate' to %s for %s", stackName, enable_auto_update, stackName)
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// expose all env variables to the app container
|
||||
func ExposeAllEnv(compose *composetypes.Config, appEnv AppEnv) {
|
||||
for _, service := range compose.Services {
|
||||
if service.Name == "app" {
|
||||
logrus.Debug("Add the following environment to the app service config:")
|
||||
for k, v := range appEnv {
|
||||
_, exists := service.Environment[k]
|
||||
if !exists {
|
||||
value := v
|
||||
service.Environment[k] = &value
|
||||
logrus.Debugf("Add Key: %s Value: %s", k, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue