66use Deployer \Exception \Exception ;
77use Deployer \Exception \GracefulShutdownException ;
88use Deployer \Host \Host ;
9- use Hypernode \Deploy \Console \ Output \ OutputWatcher ;
9+ use Hypernode \Deploy \Brancher \ BrancherHypernodeManager ;
1010use Hypernode \Deploy \Deployer \RecipeLoader ;
1111use Hypernode \Deploy \Deployer \Task \ConfigurableTaskInterface ;
1212use Hypernode \Deploy \Deployer \Task \TaskFactory ;
13- use Hypernode \Deploy \Brancher \BrancherHypernodeManager ;
1413use Hypernode \Deploy \Exception \CreateBrancherHypernodeFailedException ;
1514use Hypernode \Deploy \Exception \InvalidConfigurationException ;
1615use Hypernode \Deploy \Exception \TimeoutException ;
2120use Hypernode \DeployConfiguration \Server ;
2221use Hypernode \DeployConfiguration \Stage ;
2322use Psr \Log \LoggerInterface ;
24- use Symfony \Component \Console \Application ;
25- use Symfony \Component \Console \Input \ArrayInput ;
26- use Symfony \Component \Console \Input \InputDefinition ;
2723use Symfony \Component \Console \Input \InputInterface ;
28- use Symfony \Component \Console \Input \InputOption ;
2924use Symfony \Component \Console \Output \OutputInterface ;
3025use Throwable ;
3126
3227use function Deployer \host ;
3328use function Deployer \localhost ;
3429use function Deployer \run ;
35- use function Deployer \task ;
3630
3731class DeployRunner
3832{
@@ -43,6 +37,7 @@ class DeployRunner
4337 private InputInterface $ input ;
4438 private LoggerInterface $ log ;
4539 private RecipeLoader $ recipeLoader ;
40+ private DeployerLoader $ deployerLoader ;
4641 private ConfigurationLoader $ configurationLoader ;
4742 private BrancherHypernodeManager $ brancherHypernodeManager ;
4843
@@ -61,15 +56,17 @@ public function __construct(
6156 InputInterface $ input ,
6257 LoggerInterface $ log ,
6358 RecipeLoader $ recipeLoader ,
59+ DeployerLoader $ deployerLoader ,
6460 ConfigurationLoader $ configurationLoader ,
6561 BrancherHypernodeManager $ brancherHypernodeManager
6662 ) {
6763 $ this ->taskFactory = $ taskFactory ;
6864 $ this ->input = $ input ;
6965 $ this ->log = $ log ;
7066 $ this ->recipeLoader = $ recipeLoader ;
71- $ this ->brancherHypernodeManager = $ brancherHypernodeManager ;
67+ $ this ->deployerLoader = $ deployerLoader ;
7268 $ this ->configurationLoader = $ configurationLoader ;
69+ $ this ->brancherHypernodeManager = $ brancherHypernodeManager ;
7370 }
7471
7572 /**
@@ -79,7 +76,7 @@ public function __construct(
7976 */
8077 public function run (OutputInterface $ output , string $ stage , string $ task , bool $ configureBuildStage , bool $ configureServers ): int
8178 {
82- $ deployer = $ this ->getDeployerInstance ($ output );
79+ $ deployer = $ this ->deployerLoader -> getOrCreateInstance ($ output );
8380
8481 try {
8582 $ this ->prepare ($ configureBuildStage , $ configureServers , $ stage );
@@ -341,19 +338,4 @@ public function getDeploymentReport()
341338 $ this ->brancherHypernodesRegistered
342339 );
343340 }
344-
345- private function getDeployerInstance (OutputInterface $ output ): Deployer
346- {
347- $ console = new Application ();
348- $ deployer = new Deployer ($ console );
349- $ deployer ['output ' ] = new OutputWatcher ($ output );
350- $ deployer ['input ' ] = new ArrayInput (
351- [],
352- new InputDefinition ([
353- new InputOption ('limit ' ),
354- new InputOption ('profile ' ),
355- ])
356- );
357- return $ deployer ;
358- }
359341}
0 commit comments