big refactor
Some checks failed
continuous-integration/drone/pr Build is failing

This commit is contained in:
2024-06-24 23:20:54 +02:00
parent b688ddc4b1
commit cbab9b5907
27 changed files with 411 additions and 324 deletions

View File

@ -51,33 +51,37 @@ recipes.
app := internal.ValidateApp(c)
stackName := app.StackName()
r, err := recipe.Get(app.Recipe)
if err != nil {
logrus.Fatal(err)
}
specificVersion := c.Args().Get(1)
if specificVersion != "" && internal.Chaos {
logrus.Fatal("cannot use <version> and --chaos together")
}
if err := recipe.EnsureExists(app.Recipe); err != nil {
if err := r.EnsureExists(); err != nil {
logrus.Fatal(err)
}
if !internal.Chaos {
if err := recipe.EnsureIsClean(app.Recipe); err != nil {
if err := r.EnsureIsClean(); err != nil {
logrus.Fatal(err)
}
if !internal.Offline {
if err := recipe.EnsureUpToDate(app.Recipe); err != nil {
if err := r.EnsureUpToDate(); err != nil {
logrus.Fatal(err)
}
}
if err := recipe.EnsureLatest(app.Recipe); err != nil {
if err := r.EnsureLatest(); err != nil {
logrus.Fatal(err)
}
}
r, err := recipe.Get(app.Recipe, internal.Offline)
if err != nil {
if err := r.LoadConfig(); err != nil {
logrus.Fatal(err)
}
@ -113,7 +117,7 @@ recipes.
if len(versions) == 0 && !internal.Chaos {
logrus.Warn("no published versions in catalogue, trying local recipe repository")
recipeVersions, err := recipe.GetRecipeVersions(app.Recipe, internal.Offline)
recipeVersions, err := r.GetVersions(internal.Offline)
if err != nil {
logrus.Warn(err)
}
@ -183,7 +187,7 @@ recipes.
}
if !internal.Chaos {
if err := recipe.EnsureVersion(app.Recipe, chosenDowngrade); err != nil {
if err := r.EnsureVersion(chosenDowngrade); err != nil {
logrus.Fatal(err)
}
}
@ -191,13 +195,13 @@ recipes.
if internal.Chaos {
logrus.Warn("chaos mode engaged")
var err error
chosenDowngrade, err = recipe.ChaosVersion(app.Recipe)
chosenDowngrade, err = r.ChaosVersion()
if err != nil {
logrus.Fatal(err)
}
}
abraShPath := fmt.Sprintf("%s/%s/%s", config.RECIPES_DIR, app.Recipe, "abra.sh")
abraShPath := fmt.Sprintf("%s/%s/%s", r.Dir, "abra.sh")
abraShEnv, err := config.ReadAbraShEnvVars(abraShPath)
if err != nil {
logrus.Fatal(err)