Skip to content

Commit e6e0551

Browse files
author
Bryan Sieber
committed
Updating services
1 parent e476f81 commit e6e0551

File tree

5 files changed

+132
-20
lines changed

5 files changed

+132
-20
lines changed

poetry.lock

Lines changed: 96 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ pydantic = "^1.9.0"
1212
uvicorn = {extras = ["standard"], version = "^0.17.4"}
1313
gunicorn = "^20.1.0"
1414
prometheus-client = "^0.13.1"
15+
python-bugzilla = "^3.2.0"
16+
atlassian-python-api = "^3.20.1"
1517

1618
[tool.poetry.dev-dependencies]
1719
pre-commit = "^2.17.0"

src/app/environment.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,20 @@
66

77

88
class Settings(BaseSettings):
9-
jbi_action_key: str = "jbi"
10-
jbi_folder_path: str = "src/jbi/whiteboard_tags/"
119
port: str = "80"
1210
app_reload: bool = True
1311

12+
# JBI env vars
13+
jbi_action_key: str = "jbi"
14+
jbi_folder_path: str = "src/jbi/whiteboard_tags/"
15+
jira_base_url: str = "https://jira.allizom.org/"
16+
bugzilla_base_url: str = "https://bugzilla-dev.allizom.org/"
17+
18+
# Secrets below
19+
jira_username: str
20+
jira_password: str
21+
bugzilla_api_key: str
22+
1423

1524
@lru_cache()
1625
def get_settings() -> Settings:

src/app/monitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
def heartbeat(request: Request, settings: environment.Settings):
1313
"""Return status of backing services, as required by Dockerflow."""
1414
data: Dict = {}
15-
data.update(jbi_service_health_map(settings))
15+
data.update(jbi_service_health_map())
1616
status_code = 200
1717
for _, health in data.items():
1818
if not health.get("up"):

src/jbi/services.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
1-
# import bugzilla
2-
# import jira
1+
import bugzilla as rh_bugzilla # type: ignore
2+
from atlassian import Jira # type: ignore
33

4+
from src.app import environment
45

5-
def get_service(param=None):
6-
return param
6+
settings = environment.get_settings()
77

8+
jira = Jira(
9+
url=settings.jira_base_url,
10+
username=settings.jira_username,
11+
password=settings.jira_password,
12+
)
813

9-
def bugzilla_check_health(settings):
10-
health = {"up": False}
14+
bugzilla = rh_bugzilla.Bugzilla(
15+
settings.bugzilla_base_url, api_key=settings.bugzilla_api_key
16+
)
17+
18+
19+
def bugzilla_check_health():
20+
health = {"up": bugzilla.logged_in}
1121
return health
1222

1323

14-
def jira_check_health(settings):
24+
def jira_check_health():
25+
server_info = jira.get_server_info(True)
26+
print(server_info)
1527
health = {"up": False}
1628
return health
1729

1830

19-
def jbi_service_health_map(settings):
31+
def jbi_service_health_map():
2032
return {
21-
"bugzilla": bugzilla_check_health(settings),
22-
"jira": jira_check_health(settings),
33+
"bugzilla": bugzilla_check_health(),
34+
"jira": jira_check_health(),
2335
}

0 commit comments

Comments
 (0)