Compare commits
4 Commits
d7fda7c901
...
3d8ad75476
Author | SHA1 | Date |
---|---|---|
Massaki Archambault | 3d8ad75476 | |
Massaki Archambault | 0fb3195122 | |
Massaki Archambault | 331bdcd083 | |
Massaki Archambault | e4b0496116 |
|
@ -0,0 +1,11 @@
|
||||||
|
# v1.0.0
|
||||||
|
|
||||||
|
* Added support for Github forge
|
||||||
|
* Added support for Gitea/Forgejo forge
|
||||||
|
* **BREAKING** Renamed project from `gitlabfs` to `gitforgefs`
|
||||||
|
* **BREAKING** Added mandatory configuration *fs.forge* (no default)
|
||||||
|
* **BREAKING** Changed Gitlab user configuration to use user names instead of user ids
|
||||||
|
* Handle archived repo as hidden files by default
|
||||||
|
* Improved support for old version of git
|
||||||
|
* Fixed various race conditions
|
||||||
|
* Fixed inode collision issue
|
|
@ -28,8 +28,8 @@ gitlab:
|
||||||
group_ids:
|
group_ids:
|
||||||
- 9970 # gitlab-org
|
- 9970 # gitlab-org
|
||||||
|
|
||||||
# A list of the user ids to expose their personal projects in the filesystem.
|
# A list of the name of the user to expose their repositories un the filesystem
|
||||||
user_ids: []
|
user_names: []
|
||||||
|
|
||||||
# Set how archived projects are handled.
|
# Set how archived projects are handled.
|
||||||
# If set to "show", it will add them to the filesystem and treat them like any other project
|
# If set to "show", it will add them to the filesystem and treat them like any other project
|
||||||
|
|
|
@ -9,8 +9,8 @@ gitlab:
|
||||||
pull_method: ssh
|
pull_method: ssh
|
||||||
group_ids:
|
group_ids:
|
||||||
- 123
|
- 123
|
||||||
user_ids:
|
user_names:
|
||||||
- 456
|
- test-user
|
||||||
archived_project_handling: hide
|
archived_project_handling: hide
|
||||||
include_current_user: true
|
include_current_user: true
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ type (
|
||||||
Token string `yaml:"token,omitempty"`
|
Token string `yaml:"token,omitempty"`
|
||||||
|
|
||||||
GroupIDs []int `yaml:"group_ids,omitempty"`
|
GroupIDs []int `yaml:"group_ids,omitempty"`
|
||||||
UserIDs []int `yaml:"user_ids,omitempty"`
|
UserNames []string `yaml:"user_names,omitempty"`
|
||||||
|
|
||||||
ArchivedProjectHandling string `yaml:"archived_project_handling,omitempty"`
|
ArchivedProjectHandling string `yaml:"archived_project_handling,omitempty"`
|
||||||
IncludeCurrentUser bool `yaml:"include_current_user,omitempty"`
|
IncludeCurrentUser bool `yaml:"include_current_user,omitempty"`
|
||||||
|
@ -96,7 +96,7 @@ func LoadConfig(configPath string) (*Config, error) {
|
||||||
Token: "",
|
Token: "",
|
||||||
PullMethod: "http",
|
PullMethod: "http",
|
||||||
GroupIDs: []int{9970},
|
GroupIDs: []int{9970},
|
||||||
UserIDs: []int{},
|
UserNames: []string{},
|
||||||
ArchivedProjectHandling: "hide",
|
ArchivedProjectHandling: "hide",
|
||||||
IncludeCurrentUser: true,
|
IncludeCurrentUser: true,
|
||||||
},
|
},
|
||||||
|
|
|
@ -25,7 +25,7 @@ func TestLoadConfig(t *testing.T) {
|
||||||
Token: "12345",
|
Token: "12345",
|
||||||
PullMethod: "ssh",
|
PullMethod: "ssh",
|
||||||
GroupIDs: []int{123},
|
GroupIDs: []int{123},
|
||||||
UserIDs: []int{456},
|
UserNames: []int{456},
|
||||||
ArchivedProjectHandling: "hide",
|
ArchivedProjectHandling: "hide",
|
||||||
IncludeCurrentUser: true,
|
IncludeCurrentUser: true,
|
||||||
},
|
},
|
||||||
|
@ -148,7 +148,7 @@ func TestMakeGitlabConfig(t *testing.T) {
|
||||||
PullMethod: "http",
|
PullMethod: "http",
|
||||||
Token: "",
|
Token: "",
|
||||||
GroupIDs: []int{9970},
|
GroupIDs: []int{9970},
|
||||||
UserIDs: []int{},
|
UserNames: []int{},
|
||||||
ArchivedProjectHandling: "hide",
|
ArchivedProjectHandling: "hide",
|
||||||
IncludeCurrentUser: true,
|
IncludeCurrentUser: true,
|
||||||
},
|
},
|
||||||
|
@ -158,7 +158,7 @@ func TestMakeGitlabConfig(t *testing.T) {
|
||||||
PullMethod: "http",
|
PullMethod: "http",
|
||||||
Token: "",
|
Token: "",
|
||||||
GroupIDs: []int{9970},
|
GroupIDs: []int{9970},
|
||||||
UserIDs: []int{},
|
UserNames: []int{},
|
||||||
ArchivedProjectHandling: "hide",
|
ArchivedProjectHandling: "hide",
|
||||||
IncludeCurrentUser: true,
|
IncludeCurrentUser: true,
|
||||||
},
|
},
|
||||||
|
@ -173,7 +173,7 @@ func TestMakeGitlabConfig(t *testing.T) {
|
||||||
PullMethod: "invalid",
|
PullMethod: "invalid",
|
||||||
Token: "",
|
Token: "",
|
||||||
GroupIDs: []int{9970},
|
GroupIDs: []int{9970},
|
||||||
UserIDs: []int{},
|
UserNames: []int{},
|
||||||
ArchivedProjectHandling: "hide",
|
ArchivedProjectHandling: "hide",
|
||||||
IncludeCurrentUser: true,
|
IncludeCurrentUser: true,
|
||||||
},
|
},
|
||||||
|
@ -187,7 +187,7 @@ func TestMakeGitlabConfig(t *testing.T) {
|
||||||
PullMethod: "http",
|
PullMethod: "http",
|
||||||
Token: "",
|
Token: "",
|
||||||
GroupIDs: []int{9970},
|
GroupIDs: []int{9970},
|
||||||
UserIDs: []int{},
|
UserNames: []int{},
|
||||||
IncludeCurrentUser: true,
|
IncludeCurrentUser: true,
|
||||||
ArchivedProjectHandling: "invalid",
|
ArchivedProjectHandling: "invalid",
|
||||||
},
|
},
|
||||||
|
|
|
@ -19,6 +19,8 @@ type gitlabClient struct {
|
||||||
|
|
||||||
rootContent map[string]fstree.GroupSource
|
rootContent map[string]fstree.GroupSource
|
||||||
|
|
||||||
|
userIDs []int
|
||||||
|
|
||||||
// API response cache
|
// API response cache
|
||||||
groupCacheMux sync.RWMutex
|
groupCacheMux sync.RWMutex
|
||||||
groupCache map[int]*Group
|
groupCache map[int]*Group
|
||||||
|
@ -43,6 +45,8 @@ func NewClient(logger *slog.Logger, config config.GitlabClientConfig) (*gitlabCl
|
||||||
|
|
||||||
rootContent: nil,
|
rootContent: nil,
|
||||||
|
|
||||||
|
userIDs: []int{},
|
||||||
|
|
||||||
groupCache: map[int]*Group{},
|
groupCache: map[int]*Group{},
|
||||||
userCache: map[int]*User{},
|
userCache: map[int]*User{},
|
||||||
}
|
}
|
||||||
|
@ -52,7 +56,17 @@ func NewClient(logger *slog.Logger, config config.GitlabClientConfig) (*gitlabCl
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warn("failed to fetch the current user:", "error", err.Error())
|
logger.Warn("failed to fetch the current user:", "error", err.Error())
|
||||||
} else {
|
} else {
|
||||||
gitlabClient.UserIDs = append(gitlabClient.UserIDs, currentUser.ID)
|
gitlabClient.userIDs = append(gitlabClient.userIDs, currentUser.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch the configured users and add them to the list
|
||||||
|
for _, userName := range config.UserNames {
|
||||||
|
user, _, err := client.Users.ListUsers(&gitlab.ListUsersOptions{Username: &userName})
|
||||||
|
if err != nil || len(user) != 1 {
|
||||||
|
logger.Warn("failed to fetch the user", "userName", userName, "error", err.Error())
|
||||||
|
} else {
|
||||||
|
gitlabClient.userIDs = append(gitlabClient.userIDs, user[0].ID)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return gitlabClient, nil
|
return gitlabClient, nil
|
||||||
|
@ -72,7 +86,7 @@ func (c *gitlabClient) FetchRootGroupContent() (map[string]fstree.GroupSource, e
|
||||||
rootGroupCache[group.Name] = group
|
rootGroupCache[group.Name] = group
|
||||||
}
|
}
|
||||||
// fetch users
|
// fetch users
|
||||||
for _, uid := range c.UserIDs {
|
for _, uid := range c.userIDs {
|
||||||
user, err := c.fetchUser(uid)
|
user, err := c.fetchUser(uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -86,7 +100,7 @@ func (c *gitlabClient) FetchRootGroupContent() (map[string]fstree.GroupSource, e
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *gitlabClient) FetchGroupContent(gid uint64) (map[string]fstree.GroupSource, map[string]fstree.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)) {
|
if slices.Contains[[]int, int](c.userIDs, int(gid)) {
|
||||||
// gid is a user
|
// gid is a user
|
||||||
user, err := c.fetchUser(int(gid))
|
user, err := c.fetchUser(int(gid))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 30 KiB |
Loading…
Reference in New Issue