Expose all env vars to app container. #263

Merged
moritz merged 4 commits from moritz/abra:expose_envs into main 2023-01-31 14:13:44 +00:00
4 changed files with 20 additions and 0 deletions

View File

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

View File

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

View File

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

View File

@ -447,3 +447,20 @@ 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) {
moritz marked this conversation as resolved Outdated
// ExposeAllEnv ...
```go // ExposeAllEnv ... ```
for _, service := range compose.Services {
if service.Name == "app" {
logrus.Debugf("Add the following environment to the app service config of %s:", stackName)
moritz marked this conversation as resolved Outdated

Perhaps include the app / service / etc. info in the log message? Whatever seems appropriate.

Perhaps include the app / service / etc. info in the log message? Whatever seems appropriate.
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)
moritz marked this conversation as resolved Outdated

Same here, with some marker on the recipe/app/etc. perhaps?

Same here, with some marker on the recipe/app/etc. perhaps?
}
}
}
}
}