Skip to content

Wire executor dependencies into IoC container #7442

Description

@wbreza

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

  • Python executor can be constructed in HooksRunner.GetScriptExecutor()
  • No import cycles introduced
  • Follows existing IoC patterns from cmd/container.go
  • Tests can inject mocks without the IoC container

References

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions