feat: update snapshot management to track and filter on instance ID, migrate existing snapshots

This commit is contained in:
garethgeorge
2024-05-05 12:42:30 -07:00
committed by Gareth
parent fa851967b1
commit 8fe88a7752
10 changed files with 283 additions and 173 deletions
+15
View File
@@ -324,6 +324,21 @@ func (r *Repo) Stats(ctx context.Context, opts ...GenericOption) (*RepoStats, er
return &stats, nil
}
// AddTags adds tags to the specified snapshots.
func (r *Repo) AddTags(ctx context.Context, snapshotIDs []string, tags []string, opts ...GenericOption) error {
args := []string{"tag"}
args = append(args, "--add", strings.Join(tags, ","))
args = append(args, snapshotIDs...)
cmd := r.commandWithContext(ctx, args, opts...)
output := bytes.NewBuffer(nil)
r.pipeCmdOutputToWriter(cmd, output)
if err := cmd.Run(); err != nil {
return newCmdError(ctx, cmd, output.String(), err)
}
return nil
}
type RetentionPolicy struct {
KeepLastN int // keep the last n snapshots.
KeepHourly int // keep the last n hourly snapshots.