forget: return error if no policy was specified

This commit is contained in:
Michael Eischer 2024-04-14 22:46:49 +02:00
parent 090549c486
commit d8ba7c0889
1 changed files with 39 additions and 43 deletions

View File

@ -210,13 +210,10 @@ func runForget(ctx context.Context, opts ForgetOptions, pruneOptions PruneOption
Tags: opts.KeepTags,
}
if policy.Empty() && len(args) == 0 {
if !gopts.JSON {
Verbosef("no policy was specified, no snapshots will be removed\n")
}
if policy.Empty() {
return fmt.Errorf("no policy was specified, no snapshots will be removed")
}
if !policy.Empty() {
if !gopts.JSON {
Verbosef("Applying Policy: %v\n", policy)
}
@ -268,7 +265,6 @@ func runForget(ctx context.Context, opts ForgetOptions, pruneOptions PruneOption
}
}
}
}
if len(removeSnIDs) > 0 {
if !opts.DryRun {