mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 14:56:36 +00:00
build_manifest.py: split the request function in two
Make it so it does not depend on env variables so it will be easier to test.
This commit is contained in:
parent
6772fa76aa
commit
61c5d7b6cf
1 changed files with 9 additions and 3 deletions
|
@ -33,13 +33,19 @@ MANIFEST_TEMPLATE: str = """<?xml version="1.0" encoding="UTF-8"?>
|
|||
</manifest>"""
|
||||
|
||||
|
||||
def request(path: str) -> Dict[str, str]:
|
||||
gitlab_header: Dict[str, str] = {'JOB_TOKEN': os.environ["CI_JOB_TOKEN"]}
|
||||
base_url: str = get_hostname(os.environ['CI_PROJECT_URL'])
|
||||
def request_raw(path: str, token: str, project_url: str) -> Dict[str, str]:
|
||||
gitlab_header: Dict[str, str] = {'JOB_TOKEN': token }
|
||||
base_url: str = get_hostname(project_url)
|
||||
|
||||
return requests.get(f"https://{base_url}/api/v4/" + path, headers=gitlab_header).json()
|
||||
|
||||
|
||||
def request(path: str) -> Dict[str, str]:
|
||||
token = os.environ["CI_JOB_TOKEN"]
|
||||
project_url = os.environ['CI_PROJECT_URL']
|
||||
return request_raw(path, token, project_url)
|
||||
|
||||
|
||||
def get_hostname(url: str) -> str:
|
||||
return urlparse(url).hostname
|
||||
|
||||
|
|
Loading…
Reference in a new issue