rename fs package to fstree to avoid collision with go-fuse
This commit is contained in:
parent
5ed64d523e
commit
0c647a692f
|
@ -1,4 +1,4 @@
|
|||
package fs
|
||||
package fstree
|
||||
|
||||
import (
|
||||
"context"
|
|
@ -1,4 +1,4 @@
|
|||
package fs
|
||||
package fstree
|
||||
|
||||
import (
|
||||
"context"
|
|
@ -1,4 +1,4 @@
|
|||
package fs
|
||||
package fstree
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/hanwen/go-fuse/v2/fs"
|
||||
)
|
||||
|
||||
type RepositoryNode struct {
|
||||
type repositoryNode struct {
|
||||
fs.Inode
|
||||
param *FSParam
|
||||
|
||||
|
@ -22,10 +22,10 @@ type RepositorySource interface {
|
|||
}
|
||||
|
||||
// Ensure we are implementing the NodeReaddirer interface
|
||||
var _ = (fs.NodeReadlinker)((*RepositoryNode)(nil))
|
||||
var _ = (fs.NodeReadlinker)((*repositoryNode)(nil))
|
||||
|
||||
func newRepositoryNodeFromSource(source RepositorySource, param *FSParam) (*RepositoryNode, error) {
|
||||
node := &RepositoryNode{
|
||||
func newRepositoryNodeFromSource(source RepositorySource, param *FSParam) (*repositoryNode, error) {
|
||||
node := &repositoryNode{
|
||||
param: param,
|
||||
source: source,
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ func newRepositoryNodeFromSource(source RepositorySource, param *FSParam) (*Repo
|
|||
return node, nil
|
||||
}
|
||||
|
||||
func (n *RepositoryNode) Readlink(ctx context.Context) ([]byte, syscall.Errno) {
|
||||
func (n *repositoryNode) Readlink(ctx context.Context) ([]byte, syscall.Errno) {
|
||||
// Create the local copy of the repo
|
||||
// TODO: cleanup
|
||||
localRepositoryPath, _ := n.param.GitImplementation.CloneOrPull(n.source.GetCloneURL(), int(n.source.GetRepositoryID()), n.source.GetDefaultBranch())
|
|
@ -1,4 +1,4 @@
|
|||
package fs
|
||||
package fstree
|
||||
|
||||
import (
|
||||
"context"
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
"slices"
|
||||
|
||||
"github.com/badjware/gitlabfs/fs"
|
||||
"github.com/badjware/gitlabfs/fstree"
|
||||
"github.com/xanzy/go-gitlab"
|
||||
)
|
||||
|
||||
|
@ -27,7 +27,7 @@ type gitlabClient struct {
|
|||
client *gitlab.Client
|
||||
|
||||
// root group cache
|
||||
rootGroupCache map[string]fs.GroupSource
|
||||
rootGroupCache map[string]fstree.GroupSource
|
||||
currentUserCache *User
|
||||
|
||||
// API response cache
|
||||
|
@ -57,10 +57,10 @@ func NewClient(gitlabUrl string, gitlabToken string, p GitlabClientConfig) (*git
|
|||
return gitlabClient, nil
|
||||
}
|
||||
|
||||
func (c *gitlabClient) FetchRootGroupContent() (map[string]fs.GroupSource, error) {
|
||||
func (c *gitlabClient) FetchRootGroupContent() (map[string]fstree.GroupSource, error) {
|
||||
// use cached values if available
|
||||
if c.rootGroupCache == nil {
|
||||
rootGroupCache := make(map[string]fs.GroupSource)
|
||||
rootGroupCache := make(map[string]fstree.GroupSource)
|
||||
|
||||
// fetch root groups
|
||||
for _, gid := range c.GroupIDs {
|
||||
|
@ -92,7 +92,7 @@ func (c *gitlabClient) FetchRootGroupContent() (map[string]fs.GroupSource, error
|
|||
return c.rootGroupCache, nil
|
||||
}
|
||||
|
||||
func (c *gitlabClient) FetchGroupContent(gid uint64) (map[string]fs.GroupSource, map[string]fs.RepositorySource, error) {
|
||||
func (c *gitlabClient) FetchGroupContent(gid uint64) (map[string]fstree.GroupSource, map[string]fstree.RepositorySource, error) {
|
||||
if slices.Contains[[]int, int](c.UserIDs, int(gid)) || (c.currentUserCache != nil && c.currentUserCache.ID == int(gid)) {
|
||||
// gid is a user
|
||||
user, err := c.fetchUser(int(gid))
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/badjware/gitlabfs/fs"
|
||||
"github.com/badjware/gitlabfs/fstree"
|
||||
"github.com/xanzy/go-gitlab"
|
||||
)
|
||||
|
||||
|
@ -15,8 +15,8 @@ type Group struct {
|
|||
mux sync.Mutex
|
||||
|
||||
// group content cache
|
||||
groupCache map[string]fs.GroupSource
|
||||
projectCache map[string]fs.RepositorySource
|
||||
groupCache map[string]fstree.GroupSource
|
||||
projectCache map[string]fstree.RepositorySource
|
||||
}
|
||||
|
||||
func (g *Group) GetGroupID() uint64 {
|
||||
|
@ -58,15 +58,15 @@ func (c *gitlabClient) fetchGroup(gid int) (*Group, error) {
|
|||
return &newGroup, nil
|
||||
}
|
||||
|
||||
func (c *gitlabClient) fetchGroupContent(group *Group) (map[string]fs.GroupSource, map[string]fs.RepositorySource, error) {
|
||||
func (c *gitlabClient) fetchGroupContent(group *Group) (map[string]fstree.GroupSource, map[string]fstree.RepositorySource, error) {
|
||||
group.mux.Lock()
|
||||
defer group.mux.Unlock()
|
||||
|
||||
// Get cached data if available
|
||||
// TODO: cache cache invalidation?
|
||||
if group.groupCache == nil || group.projectCache == nil {
|
||||
groupCache := make(map[string]fs.GroupSource)
|
||||
projectCache := make(map[string]fs.RepositorySource)
|
||||
groupCache := make(map[string]fstree.GroupSource)
|
||||
projectCache := make(map[string]fstree.RepositorySource)
|
||||
|
||||
// List subgroups in path
|
||||
ListGroupsOpt := &gitlab.ListSubgroupsOptions{
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/badjware/gitlabfs/fs"
|
||||
"github.com/badjware/gitlabfs/fstree"
|
||||
"github.com/xanzy/go-gitlab"
|
||||
)
|
||||
|
||||
|
@ -15,7 +15,7 @@ type User struct {
|
|||
mux sync.Mutex
|
||||
|
||||
// user content cache
|
||||
projectCache map[string]fs.RepositorySource
|
||||
projectCache map[string]fstree.RepositorySource
|
||||
}
|
||||
|
||||
func (u *User) GetGroupID() uint64 {
|
||||
|
@ -72,14 +72,14 @@ func (c *gitlabClient) fetchCurrentUser() (*User, error) {
|
|||
return c.currentUserCache, nil
|
||||
}
|
||||
|
||||
func (c *gitlabClient) fetchUserContent(user *User) (map[string]fs.GroupSource, map[string]fs.RepositorySource, error) {
|
||||
func (c *gitlabClient) fetchUserContent(user *User) (map[string]fstree.GroupSource, map[string]fstree.RepositorySource, error) {
|
||||
user.mux.Lock()
|
||||
defer user.mux.Unlock()
|
||||
|
||||
// Get cached data if available
|
||||
// TODO: cache cache invalidation?
|
||||
if user.projectCache == nil {
|
||||
projectCache := make(map[string]fs.RepositorySource)
|
||||
projectCache := make(map[string]fstree.RepositorySource)
|
||||
|
||||
// Fetch the user repositories
|
||||
listProjectOpt := &gitlab.ListProjectsOptions{
|
||||
|
@ -105,5 +105,5 @@ func (c *gitlabClient) fetchUserContent(user *User) (map[string]fs.GroupSource,
|
|||
|
||||
user.projectCache = projectCache
|
||||
}
|
||||
return make(map[string]fs.GroupSource), user.projectCache, nil
|
||||
return make(map[string]fstree.GroupSource), user.projectCache, nil
|
||||
}
|
||||
|
|
6
main.go
6
main.go
|
@ -8,7 +8,7 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/badjware/gitlabfs/fs"
|
||||
"github.com/badjware/gitlabfs/fstree"
|
||||
"github.com/badjware/gitlabfs/git"
|
||||
"github.com/badjware/gitlabfs/gitlab"
|
||||
"gopkg.in/yaml.v2"
|
||||
|
@ -178,10 +178,10 @@ func main() {
|
|||
gitlabClient, _ := gitlab.NewClient(config.Gitlab.URL, config.Gitlab.Token, *GitlabClientConfig)
|
||||
|
||||
// Start the filesystem
|
||||
err = fs.Start(
|
||||
err = fstree.Start(
|
||||
mountpoint,
|
||||
parsedMountoptions,
|
||||
&fs.FSParam{GitImplementation: gitClient, GitPlatform: gitlabClient},
|
||||
&fstree.FSParam{GitImplementation: gitClient, GitPlatform: gitlabClient},
|
||||
*debug,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue