unstorage
unstorage copied to clipboard
feat: add `gitlab` driver
Inspired by github driver. It works in read only mode. I added tests, but removed my credentials. You should provide your own for testing. I don't know how to do otherwise...
Can you please add some basic docs too?
Live Preview ready!
| Name | Edit | Preview | Latest Commit |
|---|---|---|---|
| unstorage | Edit on Studio ↗︎ | View Live Preview | 2aa5a711fcb85ad2f8a2dc4449f069fdb83f47b7 |
I added the possibility to fetch a branch, a tag and a path in the repository.
The github driver use dir for the path in the repository, but others drivers use base (like fs, http, redis, local and session storage).
So, I switched dir to base to match others.
And I wrote basic doc !
In fact we can't fetch the root keys without per_page parameters.
And the max is 100. Should I iterate all pages to get all files ?
EDIT: I forgot renaming a variable. You can skip the following.
I should not have started with the github driver as a base. It doesn't work as expected, getKeys() don't use base as parameters.
So, I did things wrong with the base parameter.
In fact, I don't understand how I should mount the repository.
Let's say this gitlab repo at endpoint gitlab.com/user/repo with this structure
README.md
content/
- file1.md
- file2.md
public/
- image1.jpg
- image2.jpg
others/
...
How to mount only content and public dirs ?
Like I did, I can't mount two times the driver :
storage.mount('user/repo', gitlabDriver({
apiURL: source.api,
repo: 'user/repo',
base: 'content'
}))
storage.mount('user/repo', gitlabDriver({
apiURL: source.api,
repo: 'user/repo',
base: 'public'
}))
This code throw an error already mounted at user:repo.
Using storage.mount('user/repo/content',... base: 'content' return the following keys :
user:repo:content:content:file1.md
user:repo:content:content:file2.md
This is not what I intended.
I wonder how I should do ?
~~Ok. Everything looks good on another project where I fetch branches and tags only for content and public dirs. It's ready to merge!~~
No, sorry. I tested on a bigger project. I need to add the per_page parameters and iterate all pages to get all files.
I'll work on it asap...
Salut !
I changed the headers parameter to a getHeaders function. The gitlab authentication token expire in 7200 seconds. So with this function, we can return a new token. All authentication logic like the token expiry should be handled by an external library.
It also iterates all pages to get all files.
Expect #208 issue which I don't know what to do, everything looks good to me!
Any update on this @ManUtopiK? Can I provide some help to get this merged @pi0?
Any update on this @ManUtopiK?
No, I'm waiting for review...
https://github.com/pi0/tired-maintainer
Thanks for understanding 🙏🏼
Hi, thanks for this PR ! I'm using nuxt content and would love to add a source from a self-hosted gitlab repository, could this PR allow it ? If so, is any help needed ?
Thanks !
I'm using nuxt content and would love to add a source from a self-hosted gitlab repository, could this PR allow it ?
Yes !
If so, is any help needed ?
I'm still waiting for review. If you want to use it now, copy the code and import it to use with unstorage.