refactor(recipe): introduce new recipe struct and move some methods

This commit is contained in:
2024-07-07 12:35:09 +02:00
parent 9ef64778f5
commit 950f85e2b4
16 changed files with 197 additions and 167 deletions

View File

@ -17,7 +17,6 @@ import (
"coopcloud.tech/abra/pkg/config"
"coopcloud.tech/abra/pkg/log"
"coopcloud.tech/abra/pkg/recipe"
recipePkg "coopcloud.tech/abra/pkg/recipe"
"github.com/urfave/cli"
)
@ -60,23 +59,24 @@ Example:
},
Action: func(c *cli.Context) error {
app := internal.ValidateApp(c)
r := recipe.Get2(app.Name)
if err := recipe.EnsureExists(app.Recipe); err != nil {
if err := r.EnsureExists(); err != nil {
log.Fatal(err)
}
if !internal.Chaos {
if err := recipePkg.EnsureIsClean(app.Recipe); err != nil {
if err := r.EnsureIsClean(); err != nil {
log.Fatal(err)
}
if !internal.Offline {
if err := recipePkg.EnsureUpToDate(app.Recipe); err != nil {
if err := r.EnsureUpToDate(); err != nil {
log.Fatal(err)
}
}
if err := recipePkg.EnsureLatest(app.Recipe); err != nil {
if err := r.EnsureLatest(); err != nil {
log.Fatal(err)
}
}
@ -228,23 +228,24 @@ var appCmdListCommand = cli.Command{
Before: internal.SubCommandBefore,
Action: func(c *cli.Context) error {
app := internal.ValidateApp(c)
r := recipe.Get2(app.Name)
if err := recipe.EnsureExists(app.Recipe); err != nil {
if err := r.EnsureExists(); err != nil {
log.Fatal(err)
}
if !internal.Chaos {
if err := recipePkg.EnsureIsClean(app.Recipe); err != nil {
if err := r.EnsureIsClean(); err != nil {
log.Fatal(err)
}
if !internal.Offline {
if err := recipePkg.EnsureUpToDate(app.Recipe); err != nil {
if err := r.EnsureUpToDate(); err != nil {
log.Fatal(err)
}
}
if err := recipePkg.EnsureLatest(app.Recipe); err != nil {
if err := r.EnsureLatest(); err != nil {
log.Fatal(err)
}
}