aboutsummaryrefslogtreecommitdiffstats
path: root/entities/identity/resolver.go
diff options
context:
space:
mode:
authorSteve Moyer <smoyer1@selesy.com>2022-08-23 10:33:19 -0400
committerSteve Moyer <smoyer1@selesy.com>2022-08-23 10:33:19 -0400
commit7ba98bfadc2c4c7fd3e777074976b78d6171b163 (patch)
tree4865a84837a016e9a18b566046a2aa7a1992acc7 /entities/identity/resolver.go
parent2c2c449187557384fd1e5b9333e808451be86041 (diff)
parent5a70e8b3a2e0fe3d1a1dcd4c24bb6bf64633cb7f (diff)
downloadgit-bug-7ba98bfadc2c4c7fd3e777074976b78d6171b163.tar.gz
Merge branch 'master' into fix-850-ineffective-comment-edit
Diffstat (limited to 'entities/identity/resolver.go')
-rw-r--r--entities/identity/resolver.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/entities/identity/resolver.go b/entities/identity/resolver.go
new file mode 100644
index 00000000..5468a8f8
--- /dev/null
+++ b/entities/identity/resolver.go
@@ -0,0 +1,34 @@
+package identity
+
+import (
+ "github.com/MichaelMure/git-bug/entity"
+ "github.com/MichaelMure/git-bug/repository"
+)
+
+var _ entity.Resolver = &SimpleResolver{}
+
+// SimpleResolver is a Resolver loading Identities directly from a Repo
+type SimpleResolver struct {
+ repo repository.Repo
+}
+
+func NewSimpleResolver(repo repository.Repo) *SimpleResolver {
+ return &SimpleResolver{repo: repo}
+}
+
+func (r *SimpleResolver) Resolve(id entity.Id) (entity.Interface, error) {
+ return ReadLocal(r.repo, id)
+}
+
+var _ entity.Resolver = &StubResolver{}
+
+// StubResolver is a Resolver that doesn't load anything, only returning IdentityStub instances
+type StubResolver struct{}
+
+func NewStubResolver() *StubResolver {
+ return &StubResolver{}
+}
+
+func (s *StubResolver) Resolve(id entity.Id) (entity.Interface, error) {
+ return &IdentityStub{id: id}, nil
+}