(ctx context.Context, rep repo.RepositoryWriter)
| 26 | } |
| 27 | |
| 28 | func (c *commandSnapshotPin) run(ctx context.Context, rep repo.RepositoryWriter) error { |
| 29 | if len(c.addPins)+len(c.removePins) == 0 { |
| 30 | return errors.New("must specify --add and/or --remove") |
| 31 | } |
| 32 | |
| 33 | for _, id := range c.snapshotIDs { |
| 34 | m, err := snapshot.LoadSnapshot(ctx, rep, manifest.ID(id)) |
| 35 | if err == nil { |
| 36 | if err = c.pinSnapshot(ctx, rep, m); err != nil { |
| 37 | return errors.Wrapf(err, "error pinning %v", id) |
| 38 | } |
| 39 | } else if !errors.Is(err, snapshot.ErrSnapshotNotFound) { |
| 40 | return errors.Wrapf(err, "error loading snapshot %v", id) |
| 41 | } else if err := c.pinSnapshotsByRootObjectID(ctx, rep, id); err != nil { |
| 42 | return errors.Wrapf(err, "error pinning snapshots by root ID %v", id) |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | return nil |
| 47 | } |
| 48 | |
| 49 | func (c *commandSnapshotPin) pinSnapshotsByRootObjectID(ctx context.Context, rep repo.RepositoryWriter, rootID string) error { |
| 50 | rootOID, err := object.ParseID(rootID) |
nothing calls this directly
no test coverage detected