fix: inject ReloadService to API class

This commit is contained in:
Piotr Dec 2026-04-14 01:54:43 +02:00
parent 604381348a
commit 8f4dc486ac
Signed by: stawros
GPG key ID: 74B18A3F0F1E99C0
2 changed files with 7 additions and 0 deletions

View file

@ -10,6 +10,7 @@ from karl.api.models import Request
from karl.core.injects import AutowireSupport from karl.core.injects import AutowireSupport
from karl.core.woodpecker import Woodpecker from karl.core.woodpecker import Woodpecker
from karl.model.webhook import WoodpeckerEvent, ReloadEvent from karl.model.webhook import WoodpeckerEvent, ReloadEvent
from services.reload import ReloadService
router = APIRouter() router = APIRouter()
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -21,6 +22,7 @@ async def root():
@cbv(router) @cbv(router)
class APIv1: class APIv1:
reload: ReloadService = Depends(AutowireSupport.reload)
woodpecker: Woodpecker = Depends(AutowireSupport.woodpecker) woodpecker: Woodpecker = Depends(AutowireSupport.woodpecker)
bus: EventBus = Depends(AutowireSupport.bus) bus: EventBus = Depends(AutowireSupport.bus)

View file

@ -2,6 +2,7 @@ from bubus import EventBus
from injectable import inject from injectable import inject
from karl.core.woodpecker import Woodpecker from karl.core.woodpecker import Woodpecker
from services.reload import ReloadService
class AutowireSupport: class AutowireSupport:
@ -10,6 +11,10 @@ class AutowireSupport:
def woodpecker(): def woodpecker():
return inject(Woodpecker) return inject(Woodpecker)
@staticmethod
def reload():
return inject(ReloadService)
@staticmethod @staticmethod
def bus(): def bus():
return inject(EventBus) return inject(EventBus)