Allow actor override when GitHub and BBS disabled
What does this MR do and why?
This change allows an instance to selectively enable the GitHub importer or Bitbucket Server importer for a user when they are globally disabled. This is in the same vein as an MR for Direct Transfer merged in 16.5 !132431 (merged).
To override the disabled setting, the ops flags should be enabled for the user conducting the import.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
Setup:
- Go to
/admin/application_settings/general
and expand Import and export settings. - Under Import sources, uncheck
GitHub
andBitbucket Server
.
Import GitHub QA:
- On GitHub, generate a GitHub PAT for yourself
- Try to import from GitHub via the API (see the example
curl
below). You will get{"errors":["github import source is disabled"]}
- Now enable the flag for your user:
Feature.enable(:override_github_disabled, your_user)
- Try to import via the API, request will succeed.
- Verify the import worked, by visiting the project that was imported.
Import Bitbucket Server QA:
- Try to import from Bitbucket Server via the API (see the example
curl
below). You will get{"message":{"error":["bitbucket_server import source is disabled"]}}
- Now enable the flag for your user:
Feature.enable(:override_bitbucket_server_disabled, your_user)
- Try to import via the API, request will succeed.
- Verify the import worked, by visiting the project that was imported.
Example curl
to import from GitHub (imports https://github.com/lukes/test which is repo_id=743300594):
curl --request POST \
--url "http://gdk.test:3000/api/v4/import/github" \
--header "content-type: application/json" \
--header "PRIVATE-TOKEN: <GITLAB_PAT>" \
--data '{
"personal_access_token": "<GITHUB_TOKEN>",
"repo_id": "743300594",
"target_namespace": "root",
"new_name": "gh-test-import"
}'
Example curl
to import from BitBucket Server:
curl --request POST \
--url "http://gdk.test:3000/api/v4/import/bitbucket_server" \
--header "content-type: application/json" \
--header "PRIVATE-TOKEN: <GITLAB_PAT>" \
--data '{
"bitbucket_server_url": "http://localhost:7990",
"bitbucket_server_username": "admin",
"personal_access_token": "<ADMIN_PASSWORD>",
"bitbucket_server_project": "<BBS_PROJECT_CODE>",
"bitbucket_server_repo": "<BBS_REPO_NAME>",
"target_namespace": "root",
"new_name": "bbs_import"
}'
Edited by Luke Duncalfe