forked from toolshed/abra
fix: respect COMPOSE_FILE when loading compose files
Final part of coop-cloud/go-abra#57.
This commit is contained in:
@ -225,22 +225,35 @@ func GetAppStatuses(appFiles AppFiles) (map[string]string, error) {
|
||||
return statuses, nil
|
||||
}
|
||||
|
||||
// GetAppComposeFiles retrieves a compose specification for a recipe. This
|
||||
// specification is the result of a merge of all the compose.**.yml files in
|
||||
// the recipe repository.
|
||||
func GetAppComposeFiles(recipe string, appEnv AppEnv) (*composetypes.Config, error) {
|
||||
pattern := fmt.Sprintf("%s/%s/compose**yml", APPS_DIR, recipe)
|
||||
composeFiles, err := filepath.Glob(pattern)
|
||||
if err != nil {
|
||||
return &composetypes.Config{}, err
|
||||
// GetAppComposeFiles gets the list of compose files for an app which should be
|
||||
// merged into a composetypes.Config while respecting the COMPOSE_FILE env var.
|
||||
func GetAppComposeFiles(recipe string, appEnv AppEnv) ([]string, error) {
|
||||
if _, ok := appEnv["COMPOSE_FILE"]; !ok {
|
||||
pattern := fmt.Sprintf("%s/%s/compose**yml", APPS_DIR, recipe)
|
||||
composeFiles, err := filepath.Glob(pattern)
|
||||
if err != nil {
|
||||
return composeFiles, err
|
||||
}
|
||||
return composeFiles, nil
|
||||
}
|
||||
|
||||
opts := stack.Deploy{Composefiles: composeFiles}
|
||||
var composeFiles []string
|
||||
composeFileEnvVar := appEnv["COMPOSE_FILE"]
|
||||
for _, file := range strings.Split(composeFileEnvVar, ":") {
|
||||
path := fmt.Sprintf("%s/%s/%s", APPS_DIR, recipe, file)
|
||||
composeFiles = append(composeFiles, path)
|
||||
}
|
||||
return composeFiles, nil
|
||||
}
|
||||
|
||||
// GetAppComposeConfig retrieves a compose specification for a recipe. This
|
||||
// specification is the result of a merge of all the compose.**.yml files in
|
||||
// the recipe repository.
|
||||
func GetAppComposeConfig(recipe string, opts stack.Deploy, appEnv AppEnv) (*composetypes.Config, error) {
|
||||
compose, err := loader.LoadComposefile(opts, appEnv)
|
||||
if err != nil {
|
||||
return &composetypes.Config{}, err
|
||||
}
|
||||
|
||||
return compose, nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user