diff --git a/config.example.yaml b/config.example.yaml index ac13455..4dbfb1a 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -6,9 +6,9 @@ fs: # See mount.fuse(8) for the full list of options. #mountoptions: nodev,nosuid - # The git platform to use as the backend. - # Must be one of "gitlab", or "github" - platform: gitlab + # The git forge to use as the backend. + # Must be one of "gitlab" or "github" + forge: gitlab gitlab: # The gitlab url. diff --git a/config/config.test.yaml b/config/config.test.yaml index 5d21107..637c992 100644 --- a/config/config.test.yaml +++ b/config/config.test.yaml @@ -1,7 +1,7 @@ fs: mountpoint: /tmp/gitlabfs/test/mnt/gitlab mountoptions: nodev - platform: gitlab + forge: gitlab gitlab: url: https://example.com diff --git a/config/loader.go b/config/loader.go index f20f428..b785f7b 100644 --- a/config/loader.go +++ b/config/loader.go @@ -9,8 +9,8 @@ import ( ) const ( - PlatformGitlab = "gitlab" - PlatformGithub = "github" + ForgeGitlab = "gitlab" + ForgeGithub = "github" PullMethodHTTP = "http" PullMethodSSH = "ssh" @@ -30,7 +30,7 @@ type ( FSConfig struct { Mountpoint string `yaml:"mountpoint,omitempty"` MountOptions string `yaml:"mountoptions,omitempty"` - Platform string `yaml:"platform,omitempty"` + Forge string `yaml:"forge,omitempty"` } GitlabClientConfig struct { URL string `yaml:"url,omitempty"` @@ -76,7 +76,7 @@ func LoadConfig(configPath string) (*Config, error) { FS: FSConfig{ Mountpoint: "", MountOptions: "nodev,nosuid", - Platform: "", + Forge: "", }, Gitlab: GitlabClientConfig{ URL: "https://gitlab.com", @@ -119,9 +119,9 @@ func LoadConfig(configPath string) (*Config, error) { } } - // validate platform is set - if config.FS.Platform != PlatformGithub && config.FS.Platform != PlatformGitlab { - return nil, fmt.Errorf("fs.platform must be either \"%v\", or \"%v\"", PlatformGitlab, PlatformGithub) + // validate forge is set + if config.FS.Forge != ForgeGithub && config.FS.Forge != ForgeGitlab { + return nil, fmt.Errorf("fs.forge must be either \"%v\", or \"%v\"", ForgeGitlab, ForgeGithub) } return config, nil diff --git a/config/loader_test.go b/config/loader_test.go index 8b0a072..8aa3821 100644 --- a/config/loader_test.go +++ b/config/loader_test.go @@ -18,7 +18,7 @@ func TestLoadConfig(t *testing.T) { FS: config.FSConfig{ Mountpoint: "/tmp/gitlabfs/test/mnt/gitlab", MountOptions: "nodev", - Platform: "gitlab", + Forge: "gitlab", }, Gitlab: config.GitlabClientConfig{ URL: "https://example.com", @@ -70,7 +70,7 @@ func TestMakeGitConfig(t *testing.T) { "ValidConfig": { input: &config.Config{ FS: config.FSConfig{ - Platform: "gitlab", + Forge: "gitlab", }, Git: config.GitClientConfig{ CloneLocation: "/tmp", @@ -95,7 +95,7 @@ func TestMakeGitConfig(t *testing.T) { "InvalidOnClone": { input: &config.Config{ FS: config.FSConfig{ - Platform: "gitlab", + Forge: "gitlab", }, Git: config.GitClientConfig{ CloneLocation: "/tmp", @@ -132,7 +132,7 @@ func TestMakeGitlabConfig(t *testing.T) { "ValidConfig": { input: &config.Config{ FS: config.FSConfig{ - Platform: "gitlab", + Forge: "gitlab", }, Gitlab: config.GitlabClientConfig{ URL: "https://gitlab.com", @@ -157,7 +157,7 @@ func TestMakeGitlabConfig(t *testing.T) { "InvalidPullMethod": { input: &config.Config{ FS: config.FSConfig{ - Platform: "gitlab", + Forge: "gitlab", }, Gitlab: config.GitlabClientConfig{ URL: "https://gitlab.com", diff --git a/platforms/github/client.go b/forges/github/client.go similarity index 100% rename from platforms/github/client.go rename to forges/github/client.go diff --git a/platforms/github/organization.go b/forges/github/organization.go similarity index 100% rename from platforms/github/organization.go rename to forges/github/organization.go diff --git a/platforms/github/repository.go b/forges/github/repository.go similarity index 100% rename from platforms/github/repository.go rename to forges/github/repository.go diff --git a/platforms/github/user.go b/forges/github/user.go similarity index 100% rename from platforms/github/user.go rename to forges/github/user.go diff --git a/platforms/gitlab/client.go b/forges/gitlab/client.go similarity index 100% rename from platforms/gitlab/client.go rename to forges/gitlab/client.go diff --git a/platforms/gitlab/group.go b/forges/gitlab/group.go similarity index 100% rename from platforms/gitlab/group.go rename to forges/gitlab/group.go diff --git a/platforms/gitlab/project.go b/forges/gitlab/project.go similarity index 100% rename from platforms/gitlab/project.go rename to forges/gitlab/project.go diff --git a/platforms/gitlab/user.go b/forges/gitlab/user.go similarity index 100% rename from platforms/gitlab/user.go rename to forges/gitlab/user.go diff --git a/fstree/group.go b/fstree/group.go index 9f0ade0..c0f6646 100644 --- a/fstree/group.go +++ b/fstree/group.go @@ -39,7 +39,7 @@ func newGroupNodeFromSource(source GroupSource, param *FSParam) (*groupNode, err } func (n *groupNode) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) { - groups, repositories, err := n.param.GitPlatform.FetchGroupContent(n.source.GetGroupID()) + groups, repositories, err := n.param.GitForge.FetchGroupContent(n.source.GetGroupID()) if err != nil { n.param.logger.Error(err.Error()) } @@ -70,7 +70,7 @@ func (n *groupNode) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) { } func (n *groupNode) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*fs.Inode, syscall.Errno) { - groups, repositories, err := n.param.GitPlatform.FetchGroupContent(n.source.GetGroupID()) + groups, repositories, err := n.param.GitForge.FetchGroupContent(n.source.GetGroupID()) if err != nil { n.param.logger.Error(err.Error()) } else { diff --git a/fstree/root.go b/fstree/root.go index bb49cca..e044507 100644 --- a/fstree/root.go +++ b/fstree/root.go @@ -26,14 +26,14 @@ type GitClient interface { FetchLocalRepositoryPath(source RepositorySource) (string, error) } -type GitPlatform interface { +type GitForge interface { FetchRootGroupContent() (map[string]GroupSource, error) FetchGroupContent(gid uint64) (map[string]GroupSource, map[string]RepositorySource, error) } type FSParam struct { - GitClient GitClient - GitPlatform GitPlatform + GitClient GitClient + GitForge GitForge logger *slog.Logger staticInoChan chan uint64 @@ -77,7 +77,7 @@ func Start(logger *slog.Logger, mountpoint string, mountoptions []string, param } func (n *rootNode) OnAdd(ctx context.Context) { - rootGroups, err := n.param.GitPlatform.FetchRootGroupContent() + rootGroups, err := n.param.GitForge.FetchRootGroupContent() if err != nil { panic(err) } diff --git a/main.go b/main.go index 0af7f52..83fb40c 100644 --- a/main.go +++ b/main.go @@ -8,10 +8,10 @@ import ( "strings" "github.com/badjware/gitlabfs/config" + "github.com/badjware/gitlabfs/forges/github" + "github.com/badjware/gitlabfs/forges/gitlab" "github.com/badjware/gitlabfs/fstree" "github.com/badjware/gitlabfs/git" - "github.com/badjware/gitlabfs/platforms/github" - "github.com/badjware/gitlabfs/platforms/gitlab" ) func main() { @@ -65,23 +65,23 @@ func main() { } gitClient, _ := git.NewClient(logger, *gitClientParam) - var gitPlatformClient fstree.GitPlatform - if loadedConfig.FS.Platform == config.PlatformGitlab { + var gitForgeClient fstree.GitForge + if loadedConfig.FS.Forge == config.ForgeGitlab { // Create the gitlab client GitlabClientConfig, err := config.MakeGitlabConfig(loadedConfig) if err != nil { fmt.Println(err) os.Exit(1) } - gitPlatformClient, _ = gitlab.NewClient(logger, *GitlabClientConfig) - } else if loadedConfig.FS.Platform == config.PlatformGithub { + gitForgeClient, _ = gitlab.NewClient(logger, *GitlabClientConfig) + } else if loadedConfig.FS.Forge == config.ForgeGithub { // Create the github client GithubClientConfig, err := config.MakeGithubConfig(loadedConfig) if err != nil { fmt.Println(err) os.Exit(1) } - gitPlatformClient, _ = github.NewClient(logger, *GithubClientConfig) + gitForgeClient, _ = github.NewClient(logger, *GithubClientConfig) } // Start the filesystem @@ -89,7 +89,7 @@ func main() { logger, mountpoint, parsedMountoptions, - &fstree.FSParam{GitClient: gitClient, GitPlatform: gitPlatformClient}, + &fstree.FSParam{GitClient: gitClient, GitForge: gitForgeClient}, *debug, ) if err != nil {