-
Notifications
You must be signed in to change notification settings - Fork 4.6k
🎉 Source Gitlab: Ingest All Accessible Groups #11140
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
🎉 Source Gitlab: Ingest All Accessible Groups #11140
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some changes
headers = kwargs["authenticator"].get_auth_header() | ||
|
||
ids = [] | ||
|
||
r = requests.get(f'https://{kwargs["api_url"]}/api/v4/groups?page=1&per_page=50', headers=headers) | ||
results = r.json() | ||
items = map(lambda i: i['full_path'].replace('/', '%2f'), results) | ||
ids.extend(items) | ||
|
||
while 'X-Next-Page' in r.headers and r.headers['X-Next-Page'] != '': | ||
next_page = r.headers['X-Next-Page'] | ||
per_page = r.headers['X-Per-Page'] | ||
r = requests.get(f'https://{kwargs["api_url"]}/api/v4/groups?page={next_page}&per_page={per_page}', headers=headers) | ||
results = r.json() | ||
items = map(lambda i: i['full_path'].replace('/', '%2f'), results) | ||
ids.extend(items) | ||
|
||
return ids |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
headers = kwargs["authenticator"].get_auth_header() | |
ids = [] | |
r = requests.get(f'https://{kwargs["api_url"]}/api/v4/groups?page=1&per_page=50', headers=headers) | |
results = r.json() | |
items = map(lambda i: i['full_path'].replace('/', '%2f'), results) | |
ids.extend(items) | |
while 'X-Next-Page' in r.headers and r.headers['X-Next-Page'] != '': | |
next_page = r.headers['X-Next-Page'] | |
per_page = r.headers['X-Per-Page'] | |
r = requests.get(f'https://{kwargs["api_url"]}/api/v4/groups?page={next_page}&per_page={per_page}', headers=headers) | |
results = r.json() | |
items = map(lambda i: i['full_path'].replace('/', '%2f'), results) | |
ids.extend(items) | |
return ids | |
headers = kwargs["authenticator"].get_auth_header() | |
ids = [] | |
has_next = True | |
# First request params | |
per_page = 50 | |
next_page = 1 | |
while has_next: | |
r = requests.get(f'https://{kwargs["api_url"]}/api/v4/groups?page={next_page}&per_page={per_page}', headers=headers) | |
next_page = r.headers.get('X-Next-Page') | |
per_page = r.headers.get('X-Per-Page') | |
results = r.json() | |
items = map(lambda i: i['full_path'].replace('/', '%2f'), results) | |
ids.extend(items) | |
has_next = 'X-Next-Page' in r.headers and r.headers['X-Next-Page'] != '' | |
return ids |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored. This was admittedly messy :)
def get_group_list(**kwargs): | ||
headers = kwargs["authenticator"].get_auth_header() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is only used by the Source class, maybe transfer it to inside the class or let inside the source.py file. Don't see a separate file is helping here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to an internal class method on the source
…amschmidt/airbyte into marcos/test-pr-11140
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @adamschmidt I made a few changes but it's good now
Still seeing "non-json response" error messages when adding a local GITLAB source with hundreds of projects in 0.36.7-alpha (after HOURS trying to add the new gitlab source) |
What
Resolves #11128 - Allow all Gitlab groups accessible to the access token to be ingested
How
Removes the need to specify either group ids and/or project ids in the source configuration. Where neither are specified, use the Gitlab groups API to retrieve the full list of groups that are accessible to the connector and ingest as normal.
Recommended reading order
🚨 User Impact 🚨
User will no longer be forced to specify either a set of group ids or project ids, it should no longer fail when the user tries to save with blank in these fields. Existing configurations should not be impacted by this change.
Pre-merge Checklist
Updating a connector
Community member or Airbyter
airbyte_secret
./gradlew :airbyte-integrations:connectors:<name>:integrationTest
.README.md
docs/integrations/<source or destination>/<name>.md
including changelog. See changelog exampleAirbyter
If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.
/test connector=connectors/<name>
command is passing/publish
command described hereTests
Integration
Simple configuration to keep the test cycle short. Configured in
airbyte-integrations/connectors/source-gitlab/integration_tests/configured_catalog.json
Output from
python main.py read --config secrets/config.json --catalog integration_tests/configured_catalog.json
: