refactor: always validate recipe
This can slow things significantly down by requiring the catalogue and if you don't have that, cause a slow `git clone`. However, the current behvaiour is very confusing because it never actually checks if what the user passes is actually a recipe. `abra recipe fetch DOESNTEXIST` gives a better error to the user now. I'm hoping we can speed up the catalogue handling at some point.
This commit is contained in:
@ -17,7 +17,6 @@ func ValidateRecipe(args []string, cmdName string) recipe.Recipe {
|
|||||||
recipeName = args[0]
|
recipeName = args[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
if recipeName == "" && !NoInput {
|
|
||||||
var recipes []string
|
var recipes []string
|
||||||
|
|
||||||
catl, err := recipe.ReadRecipeCatalogue(Offline)
|
catl, err := recipe.ReadRecipeCatalogue(Offline)
|
||||||
@ -45,6 +44,7 @@ func ValidateRecipe(args []string, cmdName string) recipe.Recipe {
|
|||||||
recipes = append(recipes, recipeName)
|
recipes = append(recipes, recipeName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if recipeName == "" && !NoInput {
|
||||||
prompt := &survey.Select{
|
prompt := &survey.Select{
|
||||||
Message: "Select recipe",
|
Message: "Select recipe",
|
||||||
Options: recipes,
|
Options: recipes,
|
||||||
@ -58,11 +58,15 @@ func ValidateRecipe(args []string, cmdName string) recipe.Recipe {
|
|||||||
log.Fatal("no recipe name provided")
|
log.Fatal("no recipe name provided")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, ok := knownRecipes[recipeName]; !ok {
|
||||||
|
log.Fatalf("no recipe '%s' exists?", recipeName)
|
||||||
|
}
|
||||||
|
|
||||||
chosenRecipe := recipe.Get(recipeName)
|
chosenRecipe := recipe.Get(recipeName)
|
||||||
err := chosenRecipe.EnsureExists()
|
if err := chosenRecipe.EnsureExists(); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = chosenRecipe.GetComposeConfig(nil)
|
_, err = chosenRecipe.GetComposeConfig(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if cmdName == "generate" {
|
if cmdName == "generate" {
|
||||||
|
Reference in New Issue
Block a user