Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add gitlab driver #199

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

feat: add gitlab driver #199

wants to merge 10 commits into from

Conversation

ManUtopiK
Copy link

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...

@pi0 pi0 changed the title feat(driver): Gitlab feat: gitlab driver Apr 16, 2023
@pi0
Copy link
Member

pi0 commented Apr 16, 2023

Can you please add some basic docs too?

@nuxt-studio
Copy link

nuxt-studio bot commented Apr 19, 2023

Live Preview ready!

Name Edit Preview Latest Commit
unstorage Edit on Studio ↗︎ View Live Preview 2aa5a71

@ManUtopiK
Copy link
Author

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 !

@ManUtopiK
Copy link
Author

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 ?

@ManUtopiK
Copy link
Author

ManUtopiK commented Apr 19, 2023

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 ?

@ManUtopiK
Copy link
Author

ManUtopiK commented Apr 19, 2023

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...

@ManUtopiK
Copy link
Author

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!

@Hebilicious Hebilicious added the driver label Jun 30, 2023 — with Volta.net
@Hebilicious Hebilicious self-assigned this Jun 30, 2023
@Hebilicious Hebilicious self-requested a review June 30, 2023 17:36
@Hebilicious Hebilicious removed their request for review October 9, 2023 04:14
@Hebilicious Hebilicious removed their assignment Oct 9, 2023
@RomainMazB

This comment was marked as outdated.

@ManUtopiK

This comment was marked as duplicate.

@Hebilicious Hebilicious requested a review from pi0 February 20, 2024 19:39
@pi0
Copy link
Member

pi0 commented Feb 20, 2024

https://github.com/pi0/tired-maintainer

Thanks for understanding 🙏🏼

@ManUtopiK ManUtopiK changed the title feat: gitlab driver feat: add gitlab driver May 12, 2024
@arkhaiel
Copy link

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 !

@ManUtopiK
Copy link
Author

ManUtopiK commented Sep 17, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants