Skip to content

Commit f3f6c26

Browse files
committed
write README
1 parent e43d952 commit f3f6c26

File tree

2 files changed

+118
-1
lines changed

2 files changed

+118
-1
lines changed

README.md

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,118 @@
1-
# gitlabfs
1+
# gitlabfs
2+
3+
`gitlabfs` allows you to mount and navigate Gitlab groups and user personal projects as a FUSE filesystem with every groups represented as a folder and every projects represented as a symlink pointing on a local clone of the project.
4+
5+
Partial output of `tree`, truncated and with a max of 4 levels:
6+
```
7+
$ tree -L 4
8+
.
9+
├── projects
10+
│   └── gitlab-org
11+
│   ├── 5-minute-production-app
12+
│   │   ├── deploy-template -> /home/marchambault/.local/share/gitlabfs/gitlab.com/22487050
13+
│   │   ├── examples
14+
│   │   ├── hipio -> /home/marchambault/.local/share/gitlabfs/gitlab.com/23344605
15+
│   │   ├── sandbox
16+
│   │   └── static-template -> /home/marchambault/.local/share/gitlabfs/gitlab.com/23203100
17+
│   ├── allocations -> /home/marchambault/.local/share/gitlabfs/gitlab.com/684698
18+
│   ├── apilab -> /home/marchambault/.local/share/gitlabfs/gitlab.com/2383700
19+
│   ├── architecture
20+
│   │   └── tasks -> /home/marchambault/.local/share/gitlabfs/gitlab.com/22351703
21+
│   ├── async-retrospectives -> /home/marchambault/.local/share/gitlabfs/gitlab.com/7937396
22+
│   ├── auto-deploy-app -> /home/marchambault/.local/share/gitlabfs/gitlab.com/6329546
23+
│   ├── auto-deploy-helm -> /home/marchambault/.local/share/gitlabfs/gitlab.com/3651684
24+
│   ├── auto-devops-v12-10 -> /home/marchambault/.local/share/gitlabfs/gitlab.com/18629149
25+
│   ├── backstage-changelog -> /home/marchambault/.local/share/gitlabfs/gitlab.com/7602162
26+
│   ├── blob-examples -> /home/marchambault/.local/share/gitlabfs/gitlab.com/3094319
27+
│   ├── build
28+
│   │   ├── CNG -> /home/marchambault/.local/share/gitlabfs/gitlab.com/4359271
29+
│   │   ├── CNG-mirror -> /home/marchambault/.local/share/gitlabfs/gitlab.com/7682093
30+
│   │   ├── dsop-scripts -> /home/marchambault/.local/share/gitlabfs/gitlab.com/19310217
31+
│   │   ├── omnibus-mirror
32+
│   │   └── tr-test-dependency-proxy -> /home/marchambault/.local/share/gitlabfs/gitlab.com/20085049
33+
│   ├── charts
34+
│   │   ├── apparmor -> /home/marchambault/.local/share/gitlabfs/gitlab.com/18991900
35+
│   │   ├── auto-deploy-app -> /home/marchambault/.local/share/gitlabfs/gitlab.com/11915984
36+
│   │   ├── components
37+
│   │   ├── consul -> /home/marchambault/.local/share/gitlabfs/gitlab.com/18663049
38+
│   │   ├── deploy-image-helm-base -> /home/marchambault/.local/share/gitlabfs/gitlab.com/7453181
39+
│   │   ├── elastic-stack -> /home/marchambault/.local/share/gitlabfs/gitlab.com/18439881
40+
│   │   ├── fluentd-elasticsearch -> /home/marchambault/.local/share/gitlabfs/gitlab.com/17253921
41+
│   │   ├── gitlab -> /home/marchambault/.local/share/gitlabfs/gitlab.com/3828396
42+
│   │   ├── gitlab-runner -> /home/marchambault/.local/share/gitlabfs/gitlab.com/6329679
43+
│   │   ├── knative -> /home/marchambault/.local/share/gitlabfs/gitlab.com/16590122
44+
│   │   └── plantuml -> /home/marchambault/.local/share/gitlabfs/gitlab.com/14372596
45+
│   [...]
46+
└── users
47+
└── badjware
48+
└── test_project -> /home/marchambault/.local/share/gitlabfs/gitlab.com/23370783
49+
50+
696 directories, 0 files
51+
```
52+
53+
54+
## Install
55+
56+
Install [go](https://golang.org/) and run
57+
``` sh
58+
go get github.com/badjware/gitlabfs
59+
```
60+
61+
The executable will be in `$GOPATH/bin/gitlabfs` or `~/go/bin/gitlabfs` by default. For convenience, copy `gitlabfs` somewhere suitable or add `~/go/bin` in your `PATH`.
62+
63+
## Usage
64+
65+
Download the [example configuration file](./config.example.yaml) and edit the default configuration to suit your needs.
66+
67+
### Getting an API token
68+
69+
To generate an api token, log into your Gitlab instance, and go in your user settings > Access Token. Create a personal access token with the following permissions at the minimum:
70+
* `read_user`
71+
* `read_api`
72+
73+
### Getting the group ids
74+
75+
The group id can be seen just under the name of the group in Gitlab.
76+
77+
![group-id](media/group_id.jpg)
78+
79+
### Getting the user ids
80+
81+
Log into gitlab and go to https://gitlab.com/api/v4/users?username=USERNAME where `USERNAME` is the username of the user you wish to know the id of. The json response will contain the user id.
82+
83+
See https://forum.gitlab.com/t/where-is-my-user-id-in-gitlab-com/7912
84+
85+
### Mounting the filesystem
86+
87+
You can mount the filesystem with the following command:
88+
``` sh
89+
~/go/bin/gitlabfs -config /path/to/your/config.yaml /path/to/mountpoint
90+
```
91+
Once the filesystem is mounted, you can `cd` into it and navigate it like any other filesystem. The first time `ls` is run the list of groups and projects is fetched from Gitlab. This operation can take a few seconds and the command will appear frozen until it's completed. Subsequent `ls` will fetch from the cache and should be much faster.
92+
93+
If `on_clone` is set to `init` or `no-checkout`, the locally cloned project will appear empty. Simply running `git pull` manually in the project folder will sync it up with Gitlab.
94+
95+
### Unmounting the filesystem
96+
97+
To stop the filesystem, use the command `umount /path/to/mountpoint` to cleanly unmount the filesystem.
98+
99+
If `gitlabfs` is not cleanly stopped, you might start seeing the error "transport endpoint is not connected" when trying to access the mountpoint, even preventing from mounting back the filesystem on the same mountpoint. To fix this, use `umount` as root user, eg: `sudo umount /path/to/mountpoint`.
100+
101+
## Caching
102+
103+
To reduce the number of calls to the Gitlab api and improve the responsiveness of the filesystem, `gitlabfs` will cache the content of the group in memory. If a group or project is renamed, created or deleted from Gitlab, these change will not appear in the filesystem. To force `gitlabfs` to refresh its cache, use `touch .refresh` in the folder to refresh to force `gitlabfs` to query Gitlab for the list of groups and projects again.
104+
105+
While the filesystem lives in memory, the git repositories that are cloned are saved on disk. By default, they are saved in `$XDG_DATA_HOME/gitlabfs` or `$HOME/.local/share/gitlabfs`, if `$XDG_DATA_HOME` is unset. `gitlabfs` symlink to the local clone of that repo. The local clone is unaffected by project rename or archive/unarchive in Gitlab and a given project will always point to the correct local folder.
106+
107+
## Known issues / Future improvements
108+
* There is a race condition that could happen when interacting with git that needs to be fixed.
109+
* Cloning and pulling repositories is currently very resource-intensive, especially on large set of repositories. Need to track down what causes this to happen. For now, leaving `on_clone` set to `init` and `auto_pull` to `false` in the configuration avoids the issue.
110+
* Cache persists forever until a manual refresh is requested. Some way to automatically refresh would be nice.
111+
* The filesystem is currently read-only. Implementing `mkdir` to create groups, `ln` or `touch` to create projects, etc. would be nice.
112+
* Code need some cleanup and could maybe be optimized here and there.
113+
114+
## Building
115+
116+
Simply use `make` to create the executable. The executable will be in `bin/`.
117+
118+
See `make help` for all available targets.

media/group_id.jpg

30 KB
Loading

0 commit comments

Comments
 (0)