refactor(recipe): add offline and chaos options to Ensure method
This commit is contained in:
parent
950f85e2b4
commit
eee2ecda06
@ -27,7 +27,7 @@ var recipeFetchCommand = cli.Command{
|
|||||||
r := recipe.Get2(recipeName)
|
r := recipe.Get2(recipeName)
|
||||||
if recipeName != "" {
|
if recipeName != "" {
|
||||||
internal.ValidateRecipe(c)
|
internal.ValidateRecipe(c)
|
||||||
if err := r.Ensure(); err != nil {
|
if err := r.Ensure(false, false); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -41,7 +41,7 @@ var recipeFetchCommand = cli.Command{
|
|||||||
catlBar := formatter.CreateProgressbar(len(catalogue), "fetching latest recipes...")
|
catlBar := formatter.CreateProgressbar(len(catalogue), "fetching latest recipes...")
|
||||||
for recipeName := range catalogue {
|
for recipeName := range catalogue {
|
||||||
r := recipe.Get2(recipeName)
|
r := recipe.Get2(recipeName)
|
||||||
if err := r.Ensure(); err != nil {
|
if err := r.Ensure(false, false); err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
catlBar.Add(1)
|
catlBar.Add(1)
|
||||||
|
@ -275,15 +275,23 @@ type Recipe2 struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure makes sure the recipe exists, is up to date and has the latest version checked out.
|
// Ensure makes sure the recipe exists, is up to date and has the latest version checked out.
|
||||||
func (r Recipe2) Ensure() error {
|
func (r Recipe2) Ensure(chaos bool, offline bool) error {
|
||||||
if err := r.EnsureExists(); err != nil {
|
if err := r.EnsureExists(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := r.EnsureUpToDate(); err != nil {
|
|
||||||
return err
|
if !chaos {
|
||||||
}
|
if err := r.EnsureIsClean(); err != nil {
|
||||||
if err := r.EnsureLatest(); err != nil {
|
return err
|
||||||
return err
|
}
|
||||||
|
if !offline {
|
||||||
|
if err := r.EnsureUpToDate(); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := r.EnsureLatest(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user