Esempio n. 1
0
 public function saveProject($url, $branch = null)
 {
     $name = $this->getNameFromRepository($url, $branch);
     $path = escapeshellarg($this->getProjectDirectory($name));
     $url = escapeshellarg($url);
     $this->executor->executeCommand(sprintf('git clone -b %s %s %s', $branch ?: "master", $url, $path));
 }
Esempio n. 2
0
 public function getInspectResults($skipCache = false)
 {
     if (null === $this->inspectResults || true === $skipCache) {
         try {
             $data = $this->executor->executeCommand(sprintf('docker inspect %s', $this->name), null, true);
             $data = json_decode($data, true);
             $this->inspectResults = $data[0];
         } catch (ProcessFailedException $e) {
         }
     }
     return $this->inspectResults;
 }
Esempio n. 3
0
 /**
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @param bool                                              $useSudo
  * @param string                                            $ssh
  *
  * @return CommandExecutor
  */
 public function createExecutor(OutputInterface $output, $useSudo = false, $ssh = null)
 {
     $executor = new CommandExecutor();
     $executor->setOutput($output);
     if ($useSudo) {
         $executor->setDecorator(new SudoDecorator(['docker']));
     }
     $decorator = $this->getSSHDecorator($ssh);
     if ($decorator) {
         $executor->setDecorator($decorator);
     }
     return $executor;
 }
Esempio n. 4
0
 public function getRemoteIp(CommandExecutor $executor)
 {
     $matches['ip'] = '127.0.0.1';
     $decorator = $executor->getDecorator();
     if ($decorator instanceof SSHDecorator) {
         $verbose = $decorator->getVerbose();
         $decorator->setVerbose(true);
         try {
             $executor->executeCommand('exit');
         } catch (ProcessFailedException $e) {
         }
         $output = $executor->getLastErrorOutput();
         $decorator->setVerbose($verbose);
         preg_match('/^debug1: Connecting to [\\w\\d.-]+ \\[(?<ip>[\\d.]+)\\] port \\d+/m', $output, $matches);
     }
     return $matches['ip'];
 }
Esempio n. 5
0
 private function setupPostRevceiveHook($image, $volume)
 {
     $gitDir = sprintf('%s/.git', $this->getVolumePathOnTarget($image, $volume));
     $path = sprintf('%s/hooks/post-receive', $gitDir);
     $script = $this->getPostReceiveScript($image, $volume);
     $this->executor->executeCommand(sprintf('cat > %s', escapeshellarg($path)), $script);
     $this->executor->executeCommand(sprintf('chmod a+x %s', escapeshellarg($path)));
     $this->executor->executeCommand(sprintf('git --git-dir=%s config --replace-all receive.denyCurrentBranch ignore', $gitDir));
     $this->executor->executeCommand(sprintf('git --git-dir=%s config --replace-all receive.denyDeleteCurrent ignore', $gitDir));
 }