forked from coop-cloud/abra
Compare commits
14 Commits
74fd954ac4
...
72c807e31a
Author | SHA1 | Date |
---|---|---|
Moritz | 72c807e31a | |
Moritz | 8e16d2f350 | |
Moritz | b62b46a1c6 | |
Moritz | fe62b677e0 | |
Moritz | d02a049dde | |
Moritz | df42585490 | |
Moritz | ddead5dac6 | |
Moritz | 1931a9b74d | |
Moritz | 76717531bd | |
Moritz | 6774893412 | |
moritz | ebb86391af | |
moritz | 50db39424c | |
moritz | ca1ea32c46 | |
Moritz | 32851d4d99 |
|
@ -178,10 +178,10 @@ recipes.
|
|||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
config.SetUpdateLabel(compose, stackName, app.Env)
|
||||
config.ExposeAllEnv(compose, app.Env)
|
||||
config.SetChaosLabel(compose, stackName, internal.Chaos)
|
||||
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 {
|
||||
|
|
|
@ -189,10 +189,10 @@ recipes.
|
|||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
config.SetUpdateLabel(compose, stackName, app.Env)
|
||||
config.ExposeAllEnv(compose, app.Env)
|
||||
config.SetChaosLabel(compose, stackName, internal.Chaos)
|
||||
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)
|
||||
|
|
|
@ -134,10 +134,10 @@ func DeployAction(c *cli.Context) error {
|
|||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
config.SetUpdateLabel(compose, app.StackName(), app.Env)
|
||||
config.ExposeAllEnv(compose, app.Env)
|
||||
config.SetChaosLabel(compose, app.StackName(), Chaos)
|
||||
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)
|
||||
|
|
|
@ -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(compose, env)
|
||||
config.ExposeAllEnv(stackName, 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,7 +449,50 @@ func GetAppComposeConfig(recipe string, opts stack.Deploy, appEnv AppEnv) (*comp
|
|||
return compose, nil
|
||||
}
|
||||
|
||||
// add env ENABLE_AUTO_UPDATE as label to enable/disable the auto update process for this app
|
||||
// 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.
|
||||
func SetUpdateLabel(compose *composetypes.Config, stackName string, appEnv AppEnv) {
|
||||
for _, service := range compose.Services {
|
||||
if service.Name == "app" {
|
||||
|
@ -457,48 +500,9 @@ 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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