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

@ -56,28 +56,12 @@ var appSecretGenerateCommand = cli.Command{
BashComplete: autocomplete.AppNameComplete,
Action: func(c *cli.Context) error {
app := internal.ValidateApp(c)
r := recipe.Get2(app.Recipe)
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)
}
}
if len(c.Args()) == 1 && !allSecrets {
err := errors.New("missing arguments <secret>/<version> or '--all'")
internal.ShowSubcommandHelpAndError(c, err)