readRemote will read and decode a stored remote Entity from a repository
(def Definition, wrapper func(e *Entity) EntityT, repo repository.ClockedRepo, resolvers entity.Resolvers, remote string, id entity.Id)
| 71 | |
| 72 | // readRemote will read and decode a stored remote Entity from a repository |
| 73 | func readRemote[EntityT entity.Interface](def Definition, wrapper func(e *Entity) EntityT, repo repository.ClockedRepo, resolvers entity.Resolvers, remote string, id entity.Id) (EntityT, error) { |
| 74 | if err := id.Validate(); err != nil { |
| 75 | return *new(EntityT), errors.Wrap(err, "invalid id") |
| 76 | } |
| 77 | |
| 78 | ref := fmt.Sprintf("refs/remotes/%s/%s/%s", def.Namespace, remote, id.String()) |
| 79 | |
| 80 | return read[EntityT](def, wrapper, repo, resolvers, ref) |
| 81 | } |
| 82 | |
| 83 | // read fetch from git and decode an Entity at an arbitrary git reference. |
| 84 | func read[EntityT entity.Interface](def Definition, wrapper func(e *Entity) EntityT, repo repository.ClockedRepo, resolvers entity.Resolvers, ref string) (EntityT, error) { |