(ctx context.Context, rep repo.RepositoryWriter, rootID string)
| 47 | } |
| 48 | |
| 49 | func (c *commandSnapshotPin) pinSnapshotsByRootObjectID(ctx context.Context, rep repo.RepositoryWriter, rootID string) error { |
| 50 | rootOID, err := object.ParseID(rootID) |
| 51 | if err != nil { |
| 52 | return errors.Wrap(err, "unable to parse object ID") |
| 53 | } |
| 54 | |
| 55 | manifests, err := snapshot.FindSnapshotsByRootObjectID(ctx, rep, rootOID) |
| 56 | if err != nil { |
| 57 | return errors.Wrapf(err, "unable to find snapshots by root %v", rootID) |
| 58 | } |
| 59 | |
| 60 | if len(manifests) == 0 { |
| 61 | return errors.Errorf("no snapshots matched %v", rootID) |
| 62 | } |
| 63 | |
| 64 | for _, m := range manifests { |
| 65 | if err := c.pinSnapshot(ctx, rep, m); err != nil { |
| 66 | return errors.Wrap(err, "error pinning") |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | return nil |
| 71 | } |
| 72 | |
| 73 | func (c *commandSnapshotPin) pinSnapshot(ctx context.Context, rep repo.RepositoryWriter, m *snapshot.Manifest) error { |
| 74 | if !m.UpdatePins(c.addPins, c.removePins) { |
no test coverage detected