summaryrefslogtreecommitdiffstats
path: root/services/f3/driver/tree.go
diff options
context:
space:
mode:
authorDaniel Baumann <daniel@debian.org>2024-10-18 20:33:49 +0200
committerDaniel Baumann <daniel@debian.org>2024-12-12 23:57:56 +0100
commite68b9d00a6e05b3a941f63ffb696f91e554ac5ec (patch)
tree97775d6c13b0f416af55314eb6a89ef792474615 /services/f3/driver/tree.go
parentInitial commit. (diff)
downloadforgejo-e68b9d00a6e05b3a941f63ffb696f91e554ac5ec.tar.xz
forgejo-e68b9d00a6e05b3a941f63ffb696f91e554ac5ec.zip
Adding upstream version 9.0.3.
Signed-off-by: Daniel Baumann <daniel@debian.org>
Diffstat (limited to 'services/f3/driver/tree.go')
-rw-r--r--services/f3/driver/tree.go104
1 files changed, 104 insertions, 0 deletions
diff --git a/services/f3/driver/tree.go b/services/f3/driver/tree.go
new file mode 100644
index 0000000..0302ed7
--- /dev/null
+++ b/services/f3/driver/tree.go
@@ -0,0 +1,104 @@
+// Copyright Earl Warren <contact@earl-warren.org>
+// Copyright Loïc Dachary <loic@dachary.org>
+// SPDX-License-Identifier: MIT
+
+package driver
+
+import (
+ "context"
+ "fmt"
+
+ forgejo_options "code.gitea.io/gitea/services/f3/driver/options"
+
+ f3_tree "code.forgejo.org/f3/gof3/v3/tree/f3"
+ "code.forgejo.org/f3/gof3/v3/tree/generic"
+)
+
+type treeDriver struct {
+ generic.NullTreeDriver
+
+ options *forgejo_options.Options
+}
+
+func (o *treeDriver) Init() {
+ o.NullTreeDriver.Init()
+}
+
+func (o *treeDriver) Factory(ctx context.Context, kind generic.Kind) generic.NodeDriverInterface {
+ switch kind {
+ case f3_tree.KindForge:
+ return newForge()
+ case f3_tree.KindOrganizations:
+ return newOrganizations()
+ case f3_tree.KindOrganization:
+ return newOrganization()
+ case f3_tree.KindUsers:
+ return newUsers()
+ case f3_tree.KindUser:
+ return newUser()
+ case f3_tree.KindProjects:
+ return newProjects()
+ case f3_tree.KindProject:
+ return newProject()
+ case f3_tree.KindIssues:
+ return newIssues()
+ case f3_tree.KindIssue:
+ return newIssue()
+ case f3_tree.KindComments:
+ return newComments()
+ case f3_tree.KindComment:
+ return newComment()
+ case f3_tree.KindAssets:
+ return newAssets()
+ case f3_tree.KindAsset:
+ return newAsset()
+ case f3_tree.KindLabels:
+ return newLabels()
+ case f3_tree.KindLabel:
+ return newLabel()
+ case f3_tree.KindReactions:
+ return newReactions()
+ case f3_tree.KindReaction:
+ return newReaction()
+ case f3_tree.KindReviews:
+ return newReviews()
+ case f3_tree.KindReview:
+ return newReview()
+ case f3_tree.KindReviewComments:
+ return newReviewComments()
+ case f3_tree.KindReviewComment:
+ return newReviewComment()
+ case f3_tree.KindMilestones:
+ return newMilestones()
+ case f3_tree.KindMilestone:
+ return newMilestone()
+ case f3_tree.KindPullRequests:
+ return newPullRequests()
+ case f3_tree.KindPullRequest:
+ return newPullRequest()
+ case f3_tree.KindReleases:
+ return newReleases()
+ case f3_tree.KindRelease:
+ return newRelease()
+ case f3_tree.KindTopics:
+ return newTopics()
+ case f3_tree.KindTopic:
+ return newTopic()
+ case f3_tree.KindRepositories:
+ return newRepositories()
+ case f3_tree.KindRepository:
+ return newRepository(ctx)
+ case generic.KindRoot:
+ return newRoot(o.GetTree().(f3_tree.TreeInterface).NewFormat(kind))
+ default:
+ panic(fmt.Errorf("unexpected kind %s", kind))
+ }
+}
+
+func newTreeDriver(tree generic.TreeInterface, anyOptions any) generic.TreeDriverInterface {
+ driver := &treeDriver{
+ options: anyOptions.(*forgejo_options.Options),
+ }
+ driver.Init()
+ return driver
+}