Initialize container manager based on whether the ContainerHooksPath is set (#2317)

* Added tests around checking if correct manager's Initialize method has been called

* repaired missing initialization on container action handler
This commit is contained in:
Nikola Jokic
2022-12-16 15:40:49 +01:00
committed by GitHub
parent f9e2fa939c
commit 04761e5353
3 changed files with 59 additions and 5 deletions

View File

@@ -38,8 +38,17 @@ namespace GitHub.Runner.Worker.Handlers
// Update the env dictionary.
AddInputsToEnvironment();
var dockerManager = HostContext.GetService<IDockerCommandManager>();
var containerHookManager = HostContext.GetService<IContainerHookManager>();
IDockerCommandManager dockerManager = null;
IContainerHookManager containerHookManager = null;
if (FeatureManager.IsContainerHooksEnabled(ExecutionContext.Global.Variables))
{
containerHookManager = HostContext.GetService<IContainerHookManager>();
}
else
{
dockerManager = HostContext.GetService<IDockerCommandManager>();
}
string dockerFile = null;
// container image haven't built/pull