refactor: move MergeAbraShEnv to shared method

Re #638
This commit is contained in:
3wc
2025-09-03 13:32:30 -04:00
parent 7e217f8892
commit 90e9e9b5aa
5 changed files with 32 additions and 45 deletions

View File

@ -10,7 +10,9 @@ import (
appPkg "coopcloud.tech/abra/pkg/app"
"coopcloud.tech/abra/pkg/client"
"coopcloud.tech/abra/pkg/envfile"
"coopcloud.tech/abra/pkg/log"
"coopcloud.tech/abra/pkg/recipe"
"coopcloud.tech/abra/pkg/secret"
composetypes "github.com/docker/cli/cli/compose/types"
@ -18,6 +20,22 @@ import (
dockerClient "github.com/docker/docker/client"
)
// MergeAbraShEnv merges abra.sh env vars into the app env vars.
func MergeAbraShEnv(recipe recipe.Recipe, env envfile.AppEnv) error {
abraShEnv, err := envfile.ReadAbraShEnvVars(recipe.AbraShPath)
if err != nil {
return err
}
for k, v := range abraShEnv {
log.Debugf("read v:%s k: %s", v, k)
env[k] = v
}
return nil
}
// GetConfigsForStack retrieves all Docker configs attached to services in a given stack.
func GetConfigsForStack(cl *dockerClient.Client, app appPkg.App) (map[string]string, error) {
filters, err := app.Filters(false, false)
@ -185,7 +203,7 @@ func GatherImagesForDeploy(cl *dockerClient.Client, app appPkg.App, compose *com
return nil, err
}
log.Infof("Deployed images: %v", currentImages)
log.Debugf("Deployed images: %v", currentImages)
// Proposed new images from the compose files
newImages := make(map[string]string)
@ -207,7 +225,7 @@ func GatherImagesForDeploy(cl *dockerClient.Client, app appPkg.App, compose *com
}
}
}
log.Infof("Proposed images: %v", newImages)
log.Debugf("Proposed images: %v", newImages)
var imageInfo []string
for newImageName, newImageVersion := range newImages {