Compare commits

..

1 Commits

Author SHA1 Message Date
p4u1 f9754ee52f feat: fetch all recipes when no recipe is specified
continuous-integration/drone/pr Build is passing Details
2024-01-19 16:01:07 +01:00
2 changed files with 16 additions and 15 deletions

View File

@ -26,7 +26,7 @@ var recipeFetchCommand = cli.Command{
recipeName := c.Args().First()
if recipeName != "" {
internal.ValidateRecipe(c)
if err := fetchRecipe(recipeName); err != nil {
if err := recipe.Ensure(recipeName); err != nil {
logrus.Fatal(err)
}
return nil
@ -39,7 +39,7 @@ var recipeFetchCommand = cli.Command{
catlBar := formatter.CreateProgressbar(len(catalogue), "fetching latest recipes...")
for recipeName := range catalogue {
if err := fetchRecipe(recipeName); err != nil {
if err := recipe.Ensure(recipeName); err != nil {
logrus.Error(err)
}
catlBar.Add(1)
@ -48,16 +48,3 @@ var recipeFetchCommand = cli.Command{
return nil
},
}
func fetchRecipe(recipeName string) error {
if err := recipe.EnsureExists(recipeName); err != nil {
return err
}
if err := recipe.EnsureUpToDate(recipeName); err != nil {
return err
}
if err := recipe.EnsureLatest(recipeName); err != nil {
return err
}
return nil
}

View File

@ -264,6 +264,20 @@ func (r Recipe) SampleEnv() (map[string]string, error) {
return sampleEnv, nil
}
// Ensure makes sure the recipe exists, is up to date and has the latest version checked out.
func Ensure(recipeName string) error {
if err := EnsureExists(recipeName); err != nil {
return err
}
if err := EnsureUpToDate(recipeName); err != nil {
return err
}
if err := EnsureLatest(recipeName); err != nil {
return err
}
return nil
}
// EnsureExists ensures that a recipe is locally cloned
func EnsureExists(recipeName string) error {
recipeDir := path.Join(config.RECIPES_DIR, recipeName)