Wire Executor Dependencies into IoC Container
Part of #7435 — Multi-Language Hook Support
User Story
As a developer extending the hook system, I want language executors to have their tool CLI dependencies (python.Cli, node.Cli, etc.) properly injected so the system is testable and follows azd's IoC patterns.
Solution Approach
Modify cmd/container.go. The existing python.Cli is already registered as a singleton:
container.MustRegisterSingleton(python.NewCli)
Two options (choose per existing patterns):
Option A (Preferred): Register a PythonExecutorFactory singleton:
container.MustRegisterSingleton(func(pythonCli *python.Cli, commandRunner exec.CommandRunner, console input.Console) *language.PythonExecutorFactory {
return language.NewPythonExecutorFactory(pythonCli, commandRunner, console)
})
Option B: Construct on-demand in HooksRunner.GetScriptExecutor() using HooksRunner's existing serviceLocator ioc.ServiceLocator.
Update HooksRunner constructor if needed to accept python.Cli or ServiceLocator.
Files: cmd/container.go (MODIFY), possibly pkg/ext/hooks_runner.go (MODIFY)
Acceptance Criteria
References
Wire Executor Dependencies into IoC Container
Part of #7435 — Multi-Language Hook Support
User Story
As a developer extending the hook system, I want language executors to have their tool CLI dependencies (python.Cli, node.Cli, etc.) properly injected so the system is testable and follows azd's IoC patterns.
Solution Approach
Modify
cmd/container.go. The existingpython.Cliis already registered as a singleton:Two options (choose per existing patterns):
Option A (Preferred): Register a
PythonExecutorFactorysingleton:Option B: Construct on-demand in
HooksRunner.GetScriptExecutor()usingHooksRunner's existingserviceLocator ioc.ServiceLocator.Update
HooksRunnerconstructor if needed to acceptpython.CliorServiceLocator.Files:
cmd/container.go(MODIFY), possiblypkg/ext/hooks_runner.go(MODIFY)Acceptance Criteria
HooksRunner.GetScriptExecutor()cmd/container.goReferences