gitforgefs/fs/repository.go

37 lines
871 B
Go
Raw Normal View History

package fs
import (
"context"
"syscall"
"github.com/badjware/gitlabfs/gitlab"
"github.com/hanwen/go-fuse/v2/fs"
)
type RepositoryNode struct {
fs.Inode
param *FSParam
repository *gitlab.Repository
}
// Ensure we are implementing the NodeReaddirer interface
var _ = (fs.NodeReadlinker)((*RepositoryNode)(nil))
func newRepositoryNode(repository *gitlab.Repository, param *FSParam) (*RepositoryNode, error) {
2020-12-29 02:37:18 +00:00
node := &RepositoryNode{
param: param,
repository: repository,
}
2020-12-29 02:37:18 +00:00
// Passthrough the error if there is one, nothing to add here
// Errors on clone/pull are non-fatal
return node, nil
}
func (n *RepositoryNode) Readlink(ctx context.Context) ([]byte, syscall.Errno) {
2020-12-29 02:37:18 +00:00
// Create the local copy of the repo
localRepoLoc, _ := n.param.Gcp.CloneOrPull(n.repository.CloneURL, n.repository.ID, "master")
2020-12-29 02:37:18 +00:00
return []byte(localRepoLoc), 0
}