refactor: add config.GetAppComposeFiles
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user