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