refactor: use new recipe struct
This commit is contained in:
parent
356c8f8c4e
commit
9d6739a711
|
@ -3,13 +3,10 @@ package recipe
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"coopcloud.tech/abra/cli/formatter"
|
||||
"coopcloud.tech/abra/cli/internal"
|
||||
"coopcloud.tech/abra/pkg/client/stack"
|
||||
loader "coopcloud.tech/abra/pkg/client/stack"
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
"coopcloud.tech/tagcmp"
|
||||
"github.com/docker/distribution/reference"
|
||||
|
@ -23,30 +20,18 @@ var recipeLintCommand = &cli.Command{
|
|||
Aliases: []string{"l"},
|
||||
ArgsUsage: "<recipe>",
|
||||
Action: func(c *cli.Context) error {
|
||||
recipeName := internal.ValidateRecipe(c)
|
||||
|
||||
pattern := fmt.Sprintf("%s/%s/compose**yml", config.APPS_DIR, recipeName)
|
||||
composeFiles, err := filepath.Glob(pattern)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
opts := stack.Deploy{Composefiles: composeFiles}
|
||||
compose, err := loader.LoadComposefile(opts, make(map[string]string))
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
recipe := internal.ValidateRecipe(c)
|
||||
|
||||
expectedVersion := false
|
||||
if compose.Version == "3.8" {
|
||||
if recipe.Config.Version == "3.8" {
|
||||
expectedVersion = true
|
||||
}
|
||||
|
||||
envSampleProvided := false
|
||||
envSample := fmt.Sprintf("%s/%s/.env.sample", config.APPS_DIR, recipeName)
|
||||
envSample := fmt.Sprintf("%s/%s/.env.sample", config.APPS_DIR, recipe.Name)
|
||||
if _, err := os.Stat(envSample); !os.IsNotExist(err) {
|
||||
envSampleProvided = true
|
||||
}
|
||||
if err != nil {
|
||||
} else if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -56,7 +41,7 @@ var recipeLintCommand = &cli.Command{
|
|||
allImagesTagged := true
|
||||
noUnstableTags := true
|
||||
semverLikeTags := true
|
||||
for _, service := range compose.Services {
|
||||
for _, service := range recipe.Config.Services {
|
||||
if service.Name == "app" {
|
||||
serviceNamedApp = true
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue