(ctx context.Context, rep repo.RepositoryWriter)
| 51 | } |
| 52 | |
| 53 | func (c *commandSnapshotDelete) snapshotDeleteSources(ctx context.Context, rep repo.RepositoryWriter) error { |
| 54 | for _, source := range c.snapshotDeleteIDs { |
| 55 | si, err := snapshot.ParseSourceInfo(source, rep.ClientOptions().Hostname, rep.ClientOptions().Username) |
| 56 | if err != nil { |
| 57 | return errors.Wrapf(err, "invalid source '%s'", source) |
| 58 | } |
| 59 | |
| 60 | manifestIDs, err := snapshot.ListSnapshotManifests(ctx, rep, &si, nil) |
| 61 | if err != nil { |
| 62 | return errors.Wrapf(err, "error listing manifests for %v", si) |
| 63 | } |
| 64 | |
| 65 | manifests, err := snapshot.LoadSnapshots(ctx, rep, manifestIDs) |
| 66 | if err != nil { |
| 67 | return errors.Wrapf(err, "error loading manifests for %v", si) |
| 68 | } |
| 69 | |
| 70 | if len(manifests) == 0 { |
| 71 | return errors.Errorf("no snapshots for source %v", si) |
| 72 | } |
| 73 | |
| 74 | for _, m := range manifests { |
| 75 | if err := c.deleteSnapshot(ctx, rep, m); err != nil { |
| 76 | return errors.Wrap(err, "error deleting") |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | return nil |
| 82 | } |
| 83 | |
| 84 | func (c *commandSnapshotDelete) deleteSnapshot(ctx context.Context, rep repo.RepositoryWriter, m *snapshot.Manifest) error { |
| 85 | desc := fmt.Sprintf("snapshot %v of %v at %v", m.ID, m.Source, formatTimestamp(m.StartTime.ToTime())) |
no test coverage detected