Support GitHub token
This commit is contained in:
parent
d6d9ac8a7f
commit
9627729ba2
3 changed files with 6 additions and 2 deletions
|
|
@ -35,8 +35,6 @@ Contributions welcome.
|
|||
|
||||
Prototype (min required to do load testing):
|
||||
|
||||
- github token for github api requests
|
||||
- set requests otherwise requests is same as limits ?
|
||||
- plug it on a bunch of OCA and shopinvader repos to test load
|
||||
- configuring many repos in a .env file may be difficult, switch to a toml file ?
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from typing import Any
|
|||
import requests
|
||||
|
||||
from .exceptions import NotFoundOnGithub
|
||||
from .settings import settings
|
||||
|
||||
|
||||
def _github_get(url: str) -> Any:
|
||||
|
|
@ -12,6 +13,8 @@ def _github_get(url: str) -> Any:
|
|||
headers = {
|
||||
"Accept": "application/vnd.github.v3+json",
|
||||
}
|
||||
if settings.github_token:
|
||||
headers["Authorization"] = f"token {settings.github_token}"
|
||||
response = requests.get(full_url, headers)
|
||||
if response.status_code == 404:
|
||||
raise NotFoundOnGithub(f"GitHub URL not found: {full_url}.")
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from typing import Optional
|
||||
|
||||
from pydantic import BaseSettings
|
||||
|
||||
|
||||
|
|
@ -15,6 +17,7 @@ class Settings(BaseSettings):
|
|||
build_pgpassword: str
|
||||
build_admin_passwd: str
|
||||
build_domain: str
|
||||
github_token: Optional[str]
|
||||
|
||||
class Config:
|
||||
env_prefix = "RUNBOAT_"
|
||||
|
|
|
|||
Loading…
Reference in a new issue