refactor: add config.GetAppComposeFiles

This commit is contained in:
2021-08-06 19:38:06 +02:00
parent 11ef64ead3
commit 828417c92b
2 changed files with 22 additions and 19 deletions

View File

@ -6,10 +6,14 @@ import (
"io/ioutil"
"os"
"path"
"path/filepath"
"strings"
"coopcloud.tech/abra/client/convert"
"coopcloud.tech/abra/client/stack"
loader "coopcloud.tech/abra/client/stack"
"github.com/docker/cli/cli/command/stack/options"
composetypes "github.com/docker/cli/cli/compose/types"
)
// Type aliases to make code hints easier to understand
@ -221,3 +225,19 @@ func GetAppStatuses(appFiles AppFiles) (map[string]string, error) {
return statuses, nil
}
func GetAppComposeFiles(recipe string) (*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
}
opts := options.Deploy{Composefiles: composeFiles}
compose, err := loader.LoadComposefile(opts)
if err != nil {
return &composetypes.Config{}, err
}
return compose, nil
}