Inspired by the s3 VFS plugin, I’ve started an attempt to make a Git VFS plugin.
Why not just serve the worktree? I’m looking to use this to serve Forgejo/Gitea git repositories on the same VPS, and so there is no worktree. My aim is to be able to make serving a self-hosted site from a self-hosted repo as easy as:
I think it’s mostly there, but this is the first thing I’ve tried doing in Go. For some reason it seems that the configuration parameters aren’t being loaded into the FS struct .
If I can encourage anybody else to take a look at this and help, that would be great!
I’ve added some more debug statements. It looks like the parameters are being loaded correctly … then discarded??
INFO using provided configuration {"config_file": "/tmp/Caddyfile", "config_adapter": ""}
INFO caddy.fs.git thinking about {"arg": "repository"}
INFO caddy.fs.git seen 'repository' arg
INFO caddy.fs.git new value {"repository": "/tmp/testrepo"}
INFO caddy.fs.git thinking about {"arg": "revision"}
INFO caddy.fs.git seen 'revision' arg
INFO caddy.fs.git new value {"revision": "HEAD"}
INFO admin admin endpoint started {"address": "localhost:2019", "enforce_origin": false, "origins": ["//localhost:2019", "//[::1]:2019", "//127.0.0.1:2019"]}
WARN http.auto_https automatic HTTPS is completely disabled for server {"server_name": "srv0"}
INFO caddy.fs.git Parsed repository path {"repository": ""}
INFO caddy.fs.git Parsed revision path {"revision": ""}
ERROR caddy.fs.git Repository is unset
I cannot replicate the erasure you’re seeing. The values are retained and the plugin “works” (panics due to missing interface implementation). How are you running it?
Ah, I’ve recently worked out (and pushed fixes) that was due to the case of some fields in the FS struct.
Now listing directories seems to work well, but file access doesn’t: I’m guessing Caddy needs a few more methods that aren’t defined yet? I don’t actually see any panics my end though, just curl: (52) Empty reply from server.
I think I’ve worked out an approach for the seekable problem: since it looks like go-git’s object reader is non-seekable, read the entire object into a bytes.Reader, and then from that define a fs.File type that is seekable.