cgit/tasks: Allow passing extra parameters to task
This unifies with other lister tasks modules. And this allow the cgit task to be scheduled by the add-forge-now scheduler cli. Refs. swh/infra/sysadm-environment#4813
This commit is contained in:
parent
571d69f965
commit
45bbc29a52
2 changed files with 8 additions and 10 deletions
|
@ -1,8 +1,8 @@
|
|||
# Copyright (C) 2019-2021 The Software Heritage developers
|
||||
# Copyright (C) 2019 The Software Heritage developers
|
||||
# License: GNU General Public License version 3, or any later version
|
||||
# See top-level LICENSE file for more information
|
||||
|
||||
from typing import Dict, Optional
|
||||
from typing import Dict
|
||||
|
||||
from celery import shared_task
|
||||
|
||||
|
@ -10,13 +10,9 @@ from .lister import CGitLister
|
|||
|
||||
|
||||
@shared_task(name=__name__ + ".CGitListerTask")
|
||||
def list_cgit(
|
||||
url: str, instance: Optional[str] = None, base_git_url: Optional[str] = None
|
||||
) -> Dict[str, str]:
|
||||
def list_cgit(**lister_args) -> Dict[str, str]:
|
||||
"""Lister task for CGit instances"""
|
||||
lister = CGitLister.from_configfile(
|
||||
url=url, instance=instance, base_git_url=base_git_url
|
||||
)
|
||||
lister = CGitLister.from_configfile(**lister_args)
|
||||
return lister.run().dict()
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (C) 2019-2021 The Software Heritage developers
|
||||
# Copyright (C) 2019 The Software Heritage developers
|
||||
# See the AUTHORS file at the top-level directory of this distribution
|
||||
# License: GNU General Public License version 3, or any later version
|
||||
# See top-level LICENSE file for more information
|
||||
|
@ -22,7 +22,9 @@ def test_cgit_lister_task(
|
|||
lister.from_configfile.return_value = lister
|
||||
lister.run.return_value = ListerStats(pages=10, origins=500)
|
||||
|
||||
kwargs = dict(url="https://git.kernel.org/", instance="kernel", base_git_url=None)
|
||||
kwargs = dict(
|
||||
url="https://git.kernel.org/", instance="kernel", base_git_url=None, max_pages=1
|
||||
)
|
||||
|
||||
res = swh_scheduler_celery_app.send_task(
|
||||
"swh.lister.cgit.tasks.CGitListerTask",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue