Island: Register instances of INodeRepository, IMachineRepository, IAgentRepository in DI container

This commit is contained in:
Shreya Malviya 2022-09-20 15:48:07 +05:30
parent e674f3ab24
commit 51a9bad000
1 changed files with 10 additions and 0 deletions

View File

@ -24,13 +24,19 @@ from monkey_island.cc.repository import (
IAgentBinaryRepository,
IAgentConfigurationRepository,
IAgentEventRepository,
IAgentRepository,
ICredentialsRepository,
IFileRepository,
IMachineRepository,
INodeRepository,
ISimulationRepository,
IUserRepository,
JSONFileUserRepository,
LocalStorageFileRepository,
MongoAgentRepository,
MongoCredentialsRepository,
MongoMachineRepository,
MongoNodeRepository,
RetrievalError,
StubbedEventRepository,
)
@ -104,6 +110,10 @@ def _register_repositories(container: DIContainer, data_dir: Path):
# TODO: Replace with MongoEventRepository
container.register_instance(IAgentEventRepository, StubbedEventRepository())
container.register_instance(INodeRepository, container.resolve(MongoNodeRepository))
container.register_instance(IMachineRepository, container.resolve(MongoMachineRepository))
container.register_instance(IAgentRepository, container.resolve(MongoAgentRepository))
def _decorate_file_repository(file_repository: IFileRepository) -> IFileRepository:
return FileRepositoryLockingDecorator(