refactor: add config.GetAppComposeFiles
This commit is contained in:
parent
11ef64ead3
commit
828417c92b
|
@ -5,7 +5,6 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
"text/template"
|
||||
|
@ -13,10 +12,8 @@ import (
|
|||
"coopcloud.tech/abra/catalogue"
|
||||
"coopcloud.tech/abra/cli/formatter"
|
||||
"coopcloud.tech/abra/cli/internal"
|
||||
loader "coopcloud.tech/abra/client/stack"
|
||||
"coopcloud.tech/abra/config"
|
||||
|
||||
"github.com/docker/cli/cli/command/stack/options"
|
||||
"github.com/docker/distribution/reference"
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
@ -165,14 +162,7 @@ var recipeUpgradeCommand = &cli.Command{
|
|||
RecipeSkipTags map[string]string
|
||||
}
|
||||
|
||||
pattern := fmt.Sprintf("%s/%s/compose**yml", config.APPS_DIR, recipe)
|
||||
composeFiles, err := filepath.Glob(pattern)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
opts := options.Deploy{Composefiles: composeFiles}
|
||||
compose, err := loader.LoadComposefile(opts)
|
||||
compose, err := config.GetAppComposeFiles(recipe)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
@ -226,14 +216,7 @@ var recipeLintCommand = &cli.Command{
|
|||
internal.ShowSubcommandHelpAndError(c, errors.New("no recipe provided"))
|
||||
}
|
||||
|
||||
pattern := fmt.Sprintf("%s/%s/compose**yml", config.APPS_DIR, recipe)
|
||||
composeFiles, err := filepath.Glob(pattern)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
opts := options.Deploy{Composefiles: composeFiles}
|
||||
compose, err := loader.LoadComposefile(opts)
|
||||
compose, err := config.GetAppComposeFiles(recipe)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue