File tree Expand file tree Collapse file tree 7 files changed +16
-21
lines changed Expand file tree Collapse file tree 7 files changed +16
-21
lines changed Original file line number Diff line number Diff line change 23
23
24
24
import jbi
25
25
import jbi .queue
26
- from jbi .configuration import ACTIONS
26
+ from jbi .configuration import get_actions
27
27
from jbi .environment import get_settings
28
28
from jbi .log import CONFIG
29
29
from jbi .router import router
30
30
31
31
SRC_DIR = Path (__file__ ).parent
32
32
APP_DIR = Path (__file__ ).parents [1 ]
33
33
34
+ ACTIONS = get_actions ()
34
35
settings = get_settings ()
35
36
version_info : dict [str , str ] = get_version (APP_DIR )
36
37
VERSION : str = version_info ["version" ]
Original file line number Diff line number Diff line change 1
- from .models import (
2
- Bug ,
3
- BugId ,
4
- WebhookEvent ,
5
- WebhookRequest ,
6
- )
7
- from .service import BugzillaService , get_service
Original file line number Diff line number Diff line change 10
10
from jbi import environment
11
11
from jbi .models import Actions
12
12
13
- settings = environment .get_settings ()
14
13
logger = logging .getLogger (__name__ )
15
14
16
15
@@ -30,9 +29,9 @@ def get_actions_from_file(jbi_config_file: str) -> Actions:
30
29
raise ConfigError ("Errors exist." ) from exception
31
30
32
31
33
- def get_actions (env = settings . env ):
32
+ def get_actions (env = None ):
34
33
"""Load actions from file determined by ENV name"""
34
+ if env is None :
35
+ settings = environment .get_settings ()
36
+ env = settings .env
35
37
return get_actions_from_file (f"config/config.{ env } .yaml" )
36
-
37
-
38
- ACTIONS = get_actions ()
Original file line number Diff line number Diff line change 17
17
field_validator ,
18
18
)
19
19
20
- from jbi import Operation , steps
21
- from jbi .bugzilla import Bug , BugId , WebhookEvent
20
+ from jbi import Operation
21
+ from jbi .bugzilla . models import Bug , BugId , WebhookEvent
22
22
23
23
logger = logging .getLogger (__name__ )
24
24
@@ -51,6 +51,7 @@ class ActionSteps(BaseModel, frozen=True):
51
51
@classmethod
52
52
def validate_steps (cls , function_names : list [str ]):
53
53
"""Validate that all configure step functions exist in the steps module"""
54
+ from jbi import steps
54
55
55
56
invalid_functions = [
56
57
func_name for func_name in function_names if not hasattr (steps , func_name )
Original file line number Diff line number Diff line change 8
8
from dockerflow .logging import JsonLogFormatter , request_id_context
9
9
10
10
import jbi .runner as runner
11
- from jbi .configuration import ACTIONS
11
+ from jbi .configuration import get_actions
12
12
from jbi .errors import IgnoreInvalidRequestError
13
13
from jbi .queue import get_dl_queue
14
14
22
22
lsh .setFormatter (JsonLogFormatter (logger_name = __name__ ))
23
23
logger .addHandler (lsh )
24
24
25
+ ACTIONS = get_actions ()
26
+
25
27
26
28
async def retry_failed (item_executor = runner .execute_action , queue = get_dl_queue ()):
27
29
min_event_timestamp = datetime .now (UTC ) - timedelta (days = int (RETRY_TIMEOUT_DAYS ))
Original file line number Diff line number Diff line change 13
13
from fastapi .templating import Jinja2Templates
14
14
15
15
from jbi import bugzilla , jira
16
- from jbi .configuration import ACTIONS
16
+ from jbi .configuration import get_actions
17
17
from jbi .environment import Settings , get_settings
18
18
from jbi .models import Actions
19
19
from jbi .queue import DeadLetterQueue , get_dl_queue
20
20
from jbi .runner import execute_or_queue
21
21
22
22
SettingsDep = Annotated [Settings , Depends (get_settings )]
23
- ActionsDep = Annotated [Actions , Depends (lambda : ACTIONS )]
23
+ ActionsDep = Annotated [Actions , Depends (get_actions )]
24
24
BugzillaServiceDep = Annotated [bugzilla .BugzillaService , Depends (bugzilla .get_service )]
25
25
JiraServiceDep = Annotated [jira .JiraService , Depends (jira .get_service )]
26
26
Original file line number Diff line number Diff line change 4
4
Each step takes an `ActionContext` and a list of arbitrary parameters.
5
5
"""
6
6
7
- # This import is needed (as of Pyhon 3.11) to enable type checking with modules
7
+ # This import is needed (as of Python 3.11) to enable type checking with modules
8
8
# imported under `TYPE_CHECKING`
9
9
# https://docs.python.org/3/whatsnew/3.7.html#pep-563-postponed-evaluation-of-annotations
10
10
# https://docs.python.org/3/whatsnew/3.11.html#pep-563-may-not-be-the-future
19
19
from jbi import Operation
20
20
from jbi .environment import get_settings
21
21
22
- settings = get_settings ()
23
-
24
22
25
23
class StepStatus (Enum ):
26
24
"""
@@ -99,6 +97,7 @@ def add_link_to_jira(
99
97
context : ActionContext , * , bugzilla_service : BugzillaService
100
98
) -> StepResult :
101
99
"""Add the URL to the Jira issue in the `see_also` field on the Bugzilla ticket"""
100
+ settings = get_settings ()
102
101
jira_url = f"{ settings .jira_base_url } browse/{ context .jira .issue } "
103
102
logger .info (
104
103
"Link %r on Bug %s" ,
You can’t perform that action at this time.
0 commit comments