Example #1
0
 /**
  * @param DeployStep $step
  *
  * @return AbstractServer[]
  */
 public function getServersForStep(DeployStep $step)
 {
     $servers = $step->getServers();
     foreach ($servers as $server) {
         $server->setLogger($this->logger);
         $server->setCommands($step->getCommands());
     }
     return $servers;
 }
Example #2
0
 public function it_gets_servers_for_each_step_and_sets_commands(LoggerInterface $logger, DeployStep $step1, DeployStep $step2, Local $server1, Local $server2)
 {
     $server1->setCommands(['echo "step 1: command 1"', 'echo "step 1: command 2"'])->shouldBeCalled();
     $server2->setCommands(['echo "step 1: command 1"', 'echo "step 1: command 2"'])->shouldBeCalled();
     $server1->setCommands(['echo "step 2: command 1"', 'echo "step 2: command 2"'])->shouldBeCalled();
     $server1->setLogger($logger)->shouldBeCalled();
     $server2->setLogger($logger)->shouldBeCalled();
     $step1->getServers()->willReturn([$server1, $server2]);
     $step2->getServers()->willReturn([$server1]);
     $this->getServersForStep($step1)->shouldReturn([$server1, $server2]);
     $this->getServersForStep($step2)->shouldReturn([$server1]);
 }
Example #3
0
 /**
  * @param string $title
  * @param array  $config
  * @param array  $allServers
  *
  * @return DeployStep
  */
 private function createStepFromConfig($title, array $config, array $allServers)
 {
     $commands = $config['commands'];
     if (!isset($config['servers']) || $config['servers'] === 'all') {
         // Run on all servers
         $servers = array_values($allServers);
     } else {
         $servers = [];
         $config['servers'] = (array) $config['servers'];
         foreach ($config['servers'] as $serverTitle) {
             $servers[] = $allServers[$serverTitle];
         }
     }
     $step = new DeployStep($title, $commands, $servers);
     if (isset($config['mandatory'])) {
         $step->setIsMandatory((bool) $config['mandatory']);
     }
     return $step;
 }