Skip to content

Commit 9dfc002

Browse files
author
Bryan Sieber
committed
Updates to template, documentation, default_action.
1 parent d8d82ef commit 9dfc002

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

src/app/api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import uvicorn # type: ignore
99
from fastapi import FastAPI, Request
1010
from fastapi.responses import RedirectResponse
11+
from fastapi.staticfiles import StaticFiles
1112

1213
from src.app.environment import get_settings
1314
from src.app.log import configure_logging
@@ -24,6 +25,7 @@
2425

2526
app.include_router(monitor_router)
2627
app.include_router(jbi_router)
28+
app.mount("/static", StaticFiles(directory="src/static"), name="static")
2729

2830

2931
@app.get("/", include_in_schema=False)

src/jbi/router.py

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

77
from fastapi import APIRouter, Depends, Request
88
from fastapi.responses import HTMLResponse
9-
from fastapi.staticfiles import StaticFiles
109
from fastapi.templating import Jinja2Templates
1110

1211
from src.app import environment
@@ -15,7 +14,6 @@
1514
templates = Jinja2Templates(directory="src/templates")
1615

1716
api_router = APIRouter(tags=["JBI"])
18-
api_router.mount("/static", StaticFiles(directory="src/static"), name="static")
1917

2018
jbi_logger = logging.getLogger("src.jbi")
2119

src/jbi/whiteboard_actions/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ Let's create a `new_action`!
88
1. Add the python function `init` to a new "my_team_action" module, let's use the following:
99
```python
1010
def init(whiteboard_tag, jira_project_key, optional_param=42):
11-
return lambda payload, context: print("Hi world!")
11+
return lambda payload: print(f"{whiteboard_tag}, going to {jira_project_key}!")
1212
```
1313
1. In the above example `whiteboard_tag` and `jira_project_key` parameters are required
1414
1. `optional_param`, which has a default value and is not required to run this action
1515
1. init returns a `__call__`able object that the system calls with the bugzilla request and yaml configuration objects
1616
1. Using `payload` and `context` perform the desired processing!
1717
1. `payload` is bugzilla webhook payload
18-
1. `parameters` is the yaml section `parameters` as a python dict
1918
1. Use the available service calls from `src/jbi/services.py' (or make new ones)
2019
1. Now the action `src.jbi.whiteboard_actions.my_team_actions` can be added to a configuration yaml under the `action` key.

src/jbi/whiteboard_actions/default.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ def init(whiteboard_tag, jira_project_key, **kwargs):
1515

1616
class DefaultExecutor:
1717
def __init__(self, **kwargs):
18+
self.parameters = kwargs
1819
self.whiteboard_tag = kwargs.get("whiteboard_tag")
1920
self.jira_project_key = kwargs.get("jira_project_key")
2021

21-
def __call__(self, payload, parameters):
22+
def __call__(self, payload):
2223
# Called from BZ webhook
2324
# Call Jira SDK with project key etc.
2425
print(payload)
25-
print(parameters)
26+
print(self.parameters)

src/templates/powered_by_template.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</head>
66
<body>
77
<h1>{{title}}</h1>
8-
<p>{{num_configs}} collections.</p>
8+
<p>{{num_configs}} actions.</p>
99
<div id="collections">
1010
<table>
1111
<thead>
@@ -20,14 +20,14 @@ <h1>{{title}}</h1>
2020
</thead>
2121
<tbody class="list">
2222
{% for key, value in data.items() %}
23-
{% if enable_query is none or value.get("enabled") is enable_query %}
23+
{% if enable_query is none or value.enabled is enable_query %}
2424
<tr>
2525
<td class="identifier">{{key}}</td>
26-
<td class="action">{{value.get("action")}}</td>
27-
<td class="contact">{{value.get("contact")}}</td>
28-
<td class="description">{{value.get("description")}}</td>
29-
<td class="enabled">{{value.get("enabled")}}</td>
30-
<td class="parameters">{% for key, value in value["parameters"].items() %}{{key ~ ": " ~ value}}{{ ", " if not loop.last else "" }}{% endfor %}
26+
<td class="action">{{value.action}}</td>
27+
<td class="contact">{{value.contact}}</td>
28+
<td class="description">{{value.description}}</td>
29+
<td class="enabled">{{value.enabled}}</td>
30+
<td class="parameters">{% for key, value in value.parameters.items() %}{{key ~ ": " ~ value}}{{ ", " if not loop.last else "" }}{% endfor %}
3131
</td>
3232
</tr>
3333
{% endif %}

0 commit comments

Comments
 (0)