Compare commits
1 Commits
0ee2c57c09
...
f9754ee52f
Author | SHA1 | Date |
---|---|---|
p4u1 | f9754ee52f |
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue