Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove temporary Nexus data for stale or failed requests that uses "yarn" as package manager.
- Loading branch information
Showing
3 changed files
with
37 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
from cachito.workers import nexus | ||
from cachito.workers.pkg_managers.yarn import ( | ||
get_yarn_proxy_repo_name, | ||
get_yarn_proxy_repo_username, | ||
) | ||
from cachito.workers.tasks.celery import app | ||
|
||
__all__ = ["cleanup_yarn_request"] | ||
|
||
|
||
@app.task | ||
def cleanup_yarn_request(request_id): | ||
"""Clean up the Nexus yarn content for the Cachito request.""" | ||
payload = { | ||
"repository_name": get_yarn_proxy_repo_name(request_id), | ||
"username": get_yarn_proxy_repo_username(request_id), | ||
} | ||
nexus.execute_script("js_cleanup", payload) |
This file contains 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
from unittest import mock | ||
|
||
from cachito.workers.tasks import yarn | ||
|
||
|
||
@mock.patch("cachito.workers.tasks.yarn.nexus.execute_script") | ||
def test_cleanup_yarn_request(mock_exec_script): | ||
yarn.cleanup_yarn_request(42) | ||
|
||
expected_payload = { | ||
"repository_name": "cachito-yarn-42", | ||
"username": "cachito-yarn-42", | ||
} | ||
mock_exec_script.assert_called_once_with("js_cleanup", expected_payload) |