refactor(recipe): use new recipe.Ensure method

This commit is contained in:
2024-07-07 12:46:32 +02:00
parent eee2ecda06
commit 01f3f4be17
10 changed files with 20 additions and 172 deletions

View File

@ -28,28 +28,12 @@ var recipeLintCommand = cli.Command{
BashComplete: autocomplete.RecipeNameComplete,
Action: func(c *cli.Context) error {
recipe := internal.ValidateRecipe(c)
r := recipePkg.Get2(recipe.Name)
if err := r.EnsureExists(); err != nil {
if err := r.Ensure(internal.Chaos, internal.Offline); err != nil {
log.Fatal(err)
}
if !internal.Chaos {
if err := r.EnsureIsClean(); err != nil {
log.Fatal(err)
}
if !internal.Offline {
if err := r.EnsureUpToDate(); err != nil {
log.Fatal(err)
}
}
if err := r.EnsureLatest(); err != nil {
log.Fatal(err)
}
}
tableCol := []string{"ref", "rule", "severity", "satisfied", "skipped", "resolve"}
table := formatter.CreateTable(tableCol)

View File

@ -72,21 +72,9 @@ You may invoke this command in "wizard" mode and be prompted for input:
BashComplete: autocomplete.RecipeNameComplete,
Action: func(c *cli.Context) error {
recipe := internal.ValidateRecipe(c)
r := recipePkg.Get2(recipe.Name)
if err := r.EnsureIsClean(); err != nil {
log.Fatal(err)
}
if err := r.EnsureExists(); err != nil {
log.Fatal(err)
}
if err := r.EnsureUpToDate(); err != nil {
log.Fatal(err)
}
if err := r.EnsureLatest(); err != nil {
if err := r.Ensure(internal.Chaos, internal.Offline); err != nil {
log.Fatal(err)
}