pattern: Use URL network location as instance name when not provided

Make the instance parameter of the base pattern lister optional and set
lister name to URL network location when not provided.

It simplifies lister creation when associated forge type have a lot of
instances in the wild (e.g. gitlab or cgit) while giving more details
about the listed forge instance.

Also process listers for forge with multiple instances (cgit, gitea,
gitlab, phabricator and tuleap) to ensure URL network location will be
used when instance parameter is not provided.

Related to T3403
This commit is contained in:
Antoine Lambert 2021-07-13 12:33:41 +02:00
parent df46b22098
commit 6c12350863
7 changed files with 33 additions and 28 deletions

View file

@ -10,7 +10,6 @@ from urllib.parse import urljoin
import iso8601
import requests
from tenacity.before_sleep import before_sleep_log
from urllib3.util import parse_url
from swh.lister.utils import throttling_retry
from swh.scheduler.interface import SchedulerInterface
@ -51,9 +50,6 @@ class TuleapLister(StatelessLister[RepoPage]):
instance: Optional[str] = None,
credentials: CredentialsType = None,
):
if instance is None:
instance = parse_url(url).host
super().__init__(
scheduler=scheduler, credentials=credentials, url=url, instance=instance,
)