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)
|
||||
if recipeName != "" {
|
||||
internal.ValidateRecipe(c)
|
||||
if err := r.Ensure(); err != nil {
|
||||
if err := r.Ensure(false, false); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
return nil
|
||||
@ -41,7 +41,7 @@ var recipeFetchCommand = cli.Command{
|
||||
catlBar := formatter.CreateProgressbar(len(catalogue), "fetching latest recipes...")
|
||||
for recipeName := range catalogue {
|
||||
r := recipe.Get2(recipeName)
|
||||
if err := r.Ensure(); err != nil {
|
||||
if err := r.Ensure(false, false); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
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.
|
||||
func (r Recipe2) Ensure() error {
|
||||
func (r Recipe2) Ensure(chaos bool, offline bool) error {
|
||||
if err := r.EnsureExists(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := r.EnsureUpToDate(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := r.EnsureLatest(); err != nil {
|
||||
return err
|
||||
|
||||
if !chaos {
|
||||
if err := r.EnsureIsClean(); err != nil {
|
||||
return err
|
||||
}
|
||||
if !offline {
|
||||
if err := r.EnsureUpToDate(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
if err := r.EnsureLatest(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user