fix: ensure latest checked out for recipe upgrade

This commit is contained in:
2022-01-29 13:35:42 +01:00
parent c905376472
commit b2d17a1829
5 changed files with 11 additions and 5 deletions

View File

@ -45,7 +45,7 @@ func ValidateRecipe(c *cli.Context) recipe.Recipe {
// ValidateRecipeWithPrompt ensures a recipe argument is present before
// validating, asking for input if required.
func ValidateRecipeWithPrompt(c *cli.Context) recipe.Recipe {
func ValidateRecipeWithPrompt(c *cli.Context, ensureLatest bool) recipe.Recipe {
recipeName := c.Args().First()
if recipeName == "" && !NoInput {
@ -94,6 +94,12 @@ func ValidateRecipeWithPrompt(c *cli.Context) recipe.Recipe {
ShowSubcommandHelpAndError(c, errors.New("no recipe name provided"))
}
if ensureLatest {
if err := recipe.EnsureLatest(recipeName); err != nil {
logrus.Fatal(err)
}
}
chosenRecipe, err := recipe.Get(recipeName)
if err != nil {
logrus.Fatal(err)