- Notifications
You must be signed in to change notification settings - Fork676
feat: add remote import s3#2357
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
2 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
14 changes: 14 additions & 0 deletionsdocs/gl_objects/projects.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
66 changes: 64 additions & 2 deletionsgitlab/v4/objects/projects.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
22 changes: 21 additions & 1 deletiontests/functional/api/test_import_export.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -69,7 +69,7 @@ def test_project_import_export(gl, project, temp_dir): | ||
def test_project_remote_import(gl): | ||
with pytest.raises(gitlab.exceptions.GitlabImportError) as err_info: | ||
gl.projects.remote_import( | ||
"ftp://whatever.com/url", "remote-project", "remote-project", "root" | ||
) | ||
@@ -78,3 +78,23 @@ def test_project_remote_import(gl): | ||
"File url is blocked: Only allowed schemes are https" | ||
in err_info.value.error_message | ||
) | ||
def test_project_remote_import_s3(gl): | ||
gl.features.set("import_project_from_remote_file_s3", True) | ||
with pytest.raises(gitlab.exceptions.GitlabImportError) as err_info: | ||
gl.projects.remote_import_s3( | ||
"remote-project", | ||
"aws-region", | ||
"aws-bucket-name", | ||
"aws-file-key", | ||
"aws-access-key-id", | ||
"secret-access-key", | ||
"remote-project", | ||
"root", | ||
) | ||
nejch marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
assert err_info.value.response_code == 400 | ||
assert ( | ||
"Failed to open 'aws-file-key' in 'aws-bucket-name'" | ||
in err_info.value.error_message | ||
) | ||
nejch marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. |
43 changes: 42 additions & 1 deletiontests/unit/objects/test_project_import_export.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -53,6 +53,30 @@ def resp_remote_import(): | ||
yield rsps | ||
@pytest.fixture | ||
def resp_remote_import_s3(): | ||
content = { | ||
"id": 1, | ||
"description": None, | ||
"name": "remote-project-s3", | ||
"name_with_namespace": "Administrator / remote-project-s3", | ||
"path": "remote-project-s3", | ||
"path_with_namespace": "root/remote-project-s3", | ||
"created_at": "2018-02-13T09:05:58.023Z", | ||
"import_status": "scheduled", | ||
} | ||
nejch marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
with responses.RequestsMock() as rsps: | ||
rsps.add( | ||
method=responses.POST, | ||
url="http://localhost/api/v4/projects/remote-import-s3", | ||
json=content, | ||
content_type="application/json", | ||
status=200, | ||
) | ||
yield rsps | ||
@pytest.fixture | ||
def resp_import_status(): | ||
content = { | ||
@@ -125,7 +149,24 @@ def test_import_project(gl, resp_import_project): | ||
def test_remote_import(gl, resp_remote_import): | ||
project_import = gl.projects.remote_import( | ||
"https://whatever.com/url/file.tar.gz", | ||
"remote-project", | ||
"remote-project", | ||
"root", | ||
) | ||
assert project_import["import_status"] == "scheduled" | ||
def test_remote_import_s3(gl, resp_remote_import_s3): | ||
project_import = gl.projects.remote_import_s3( | ||
"remote-project", | ||
"aws-region", | ||
"aws-bucket-name", | ||
"aws-file-key", | ||
"aws-access-key-id", | ||
"secret-access-key", | ||
"remote-project", | ||
"root", | ||
) | ||
assert project_import["import_status"] == "scheduled" | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.