refactor: recipe validation

This commit is contained in:
2021-09-05 01:55:10 +02:00
parent 317be4cc01
commit c99f0fc908
7 changed files with 106 additions and 86 deletions

View File

@ -9,6 +9,7 @@ import (
abraFormatter "coopcloud.tech/abra/cli/formatter"
"coopcloud.tech/abra/cli/internal"
"coopcloud.tech/abra/config"
"coopcloud.tech/abra/recipe"
"coopcloud.tech/abra/secret"
"github.com/AlecAivazis/survey/v2"
"github.com/sirupsen/logrus"
@ -87,15 +88,15 @@ func getRecipe(recipeName string) (catalogue.Recipe, error) {
return catalogue.Recipe{}, err
}
recipe, ok := catl[recipeName]
rec, ok := catl[recipeName]
if !ok {
return catalogue.Recipe{}, fmt.Errorf("recipe '%s' does not exist?", recipeName)
}
if err := recipe.EnsureExists(); err != nil {
if err := recipe.EnsureExists(rec.Name); err != nil {
return catalogue.Recipe{}, err
}
return recipe, nil
return rec, nil
}
// ensureDomainFlag checks if the domain flag was used. if not, asks the user for it/
@ -180,12 +181,12 @@ func action(c *cli.Context) error {
logrus.Fatal(err)
}
recipe, err := getRecipe(recipeName)
rec, err := getRecipe(recipeName)
if err != nil {
logrus.Fatal(err)
}
latestVersion := recipe.LatestVersion()
latestVersion := rec.LatestVersion()
if err := recipe.EnsureVersion(latestVersion); err != nil {
logrus.Fatal(err)
}