@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | 'projects' => array(), |
| 54 | 54 | ); |
| 55 | 55 | |
| 56 | - if ($request->httpMethod() != 'GET') { |
|
| 56 | + if($request->httpMethod() != 'GET') { |
|
| 57 | 57 | return $this->message('API not found', 404); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - foreach (DNProject::get() as $item) { |
|
| 61 | - if ($item->canView($this->getMember())) { |
|
| 60 | + foreach(DNProject::get() as $item) { |
|
| 61 | + if($item->canView($this->getMember())) { |
|
| 62 | 62 | $response['projects'][] = array( |
| 63 | 63 | "name" => $item->Name, |
| 64 | 64 | "href" => Director::absoluteURL($item->APILink("")), |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | public function project(SS_HTTPRequest $request) |
| 79 | 79 | { |
| 80 | 80 | $project = $this->getProject(); |
| 81 | - if (!$project) { |
|
| 81 | + if(!$project) { |
|
| 82 | 82 | return $this->project404Response(); |
| 83 | 83 | } |
| 84 | 84 | return new APIProject($this, $project); |
@@ -93,12 +93,12 @@ discard block |
||
| 93 | 93 | public function environment(SS_HTTPRequest $request) |
| 94 | 94 | { |
| 95 | 95 | $project = $this->getProject(); |
| 96 | - if (!$project) { |
|
| 96 | + if(!$project) { |
|
| 97 | 97 | return $this->project404Response(); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | $environment = $this->getEnvironment(); |
| 101 | - if (!$environment) { |
|
| 101 | + if(!$environment) { |
|
| 102 | 102 | return $this->environment404Response(); |
| 103 | 103 | } |
| 104 | 104 | return new APIEnvironment($this, $environment); |
@@ -17,10 +17,10 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | public function index(SS_HTTPRequest $request) |
| 19 | 19 | { |
| 20 | - if (!$this->record->canView($this->getMember())) { |
|
| 20 | + if(!$this->record->canView($this->getMember())) { |
|
| 21 | 21 | return $this->message('You are not authorized to view this environment', 403); |
| 22 | 22 | } |
| 23 | - switch ($request->httpMethod()) { |
|
| 23 | + switch($request->httpMethod()) { |
|
| 24 | 24 | case 'GET': |
| 25 | 25 | $href = Director::absoluteURL($this->record->Project()->APILink($this->record->Name)); |
| 26 | 26 | return $this->getAPIResponse(array( |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function ping(SS_HTTPRequest $request) |
| 56 | 56 | { |
| 57 | - if (!$this->record->canView($this->getMember())) { |
|
| 57 | + if(!$this->record->canView($this->getMember())) { |
|
| 58 | 58 | return $this->message('You are not authorized to do that on this environment', 403); |
| 59 | 59 | } |
| 60 | - switch ($request->httpMethod()) { |
|
| 60 | + switch($request->httpMethod()) { |
|
| 61 | 61 | case 'GET': |
| 62 | 62 | return $this->getPing($this->getRequest()->param('ID')); |
| 63 | 63 | case 'POST': |
@@ -73,10 +73,10 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function deploy(SS_HTTPRequest $request) |
| 75 | 75 | { |
| 76 | - if (!$this->record->canView($this->getMember())) { |
|
| 76 | + if(!$this->record->canView($this->getMember())) { |
|
| 77 | 77 | return $this->message('You are not authorized to do that on this environment', 403); |
| 78 | 78 | } |
| 79 | - switch ($request->httpMethod()) { |
|
| 79 | + switch($request->httpMethod()) { |
|
| 80 | 80 | case 'GET': |
| 81 | 81 | return $this->getDeploy($this->getRequest()->param('ID')); |
| 82 | 82 | case 'POST': |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | protected function createPing() |
| 113 | 113 | { |
| 114 | - if (!$this->record->canDeploy($this->getMember())) { |
|
| 114 | + if(!$this->record->canDeploy($this->getMember())) { |
|
| 115 | 115 | return $this->message('You are not authorized to do that on this environment', 403); |
| 116 | 116 | } |
| 117 | 117 | $ping = DNPing::create(); |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | protected function getPing($ID) |
| 139 | 139 | { |
| 140 | 140 | $ping = DNPing::get()->byID($ID); |
| 141 | - if (!$ping) { |
|
| 141 | + if(!$ping) { |
|
| 142 | 142 | return $this->message('Ping not found', 404); |
| 143 | 143 | } |
| 144 | 144 | $output = array( |
@@ -154,17 +154,17 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | protected function createDeploy() |
| 156 | 156 | { |
| 157 | - if (!$this->record->canDeploy($this->getMember())) { |
|
| 157 | + if(!$this->record->canDeploy($this->getMember())) { |
|
| 158 | 158 | return $this->message('You are not authorized to do that on this environment', 403); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | $reqBody = $this->getRequestBody(); |
| 162 | 162 | |
| 163 | - if ($reqBody === null) { |
|
| 163 | + if($reqBody === null) { |
|
| 164 | 164 | return $this->message('the request body did not contain a valid JSON object.', 400); |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - if (empty($reqBody['release'])) { |
|
| 167 | + if(empty($reqBody['release'])) { |
|
| 168 | 168 | return $this->message('deploy requires a {"release": "sha1"} in the body of the request.', 400); |
| 169 | 169 | } |
| 170 | 170 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | protected function getDeploy($id) |
| 192 | 192 | { |
| 193 | 193 | $deploy = DNDeployment::get()->byID($id); |
| 194 | - if (!$deploy) { |
|
| 194 | + if(!$deploy) { |
|
| 195 | 195 | return $this->message('Deploy not found', 404); |
| 196 | 196 | } |
| 197 | 197 | $output = array( |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | protected function getAPIResponse($output) |
| 66 | 66 | { |
| 67 | 67 | $response = $this->getResponse(); |
| 68 | - if ($this->respondWithText()) { |
|
| 68 | + if($this->respondWithText()) { |
|
| 69 | 69 | $body = print_r($output, true); |
| 70 | 70 | $response->addHeader('Content-Type', 'text/plain'); |
| 71 | 71 | } else { |
@@ -81,10 +81,10 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | protected function respondWithJSON() |
| 83 | 83 | { |
| 84 | - if ($this->getRequest()->getExtension() == 'json') { |
|
| 84 | + if($this->getRequest()->getExtension() == 'json') { |
|
| 85 | 85 | return true; |
| 86 | 86 | } |
| 87 | - if (strpos($this->getRequest()->getHeader('Accept'), 'application/json') !== false) { |
|
| 87 | + if(strpos($this->getRequest()->getHeader('Accept'), 'application/json') !== false) { |
|
| 88 | 88 | return true; |
| 89 | 89 | } |
| 90 | 90 | return false; |
@@ -95,10 +95,10 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | protected function respondWithText() |
| 97 | 97 | { |
| 98 | - if ($this->getRequest()->getExtension() == 'txt') { |
|
| 98 | + if($this->getRequest()->getExtension() == 'txt') { |
|
| 99 | 99 | return true; |
| 100 | 100 | } |
| 101 | - if (strpos($this->getRequest()->getHeader('Accept'), 'text/plain') !== false) { |
|
| 101 | + if(strpos($this->getRequest()->getHeader('Accept'), 'text/plain') !== false) { |
|
| 102 | 102 | return true; |
| 103 | 103 | } |
| 104 | 104 | return false; |
@@ -17,11 +17,11 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | public function index(SS_HTTPRequest $request) |
| 19 | 19 | { |
| 20 | - if (!$this->record->canView($this->getMember())) { |
|
| 20 | + if(!$this->record->canView($this->getMember())) { |
|
| 21 | 21 | return $this->message('You are not authorized to this environment', 403); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - switch ($request->httpMethod()) { |
|
| 24 | + switch($request->httpMethod()) { |
|
| 25 | 25 | case 'GET': |
| 26 | 26 | $response = array( |
| 27 | 27 | "name" => $this->record->Name, |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | "disk-quota-mb" => $this->record->DiskQuotaMB, |
| 32 | 32 | "environments" => array(), |
| 33 | 33 | ); |
| 34 | - foreach ($this->record->DNEnvironmentList() as $environment) { |
|
| 34 | + foreach($this->record->DNEnvironmentList() as $environment) { |
|
| 35 | 35 | $response['environments'][] = array( |
| 36 | 36 | 'name' => $environment->Name, |
| 37 | 37 | 'href' => Director::absoluteURL($this->record->APILink($environment->Name)), |
@@ -50,10 +50,10 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function fetch(SS_HTTPRequest $request) |
| 52 | 52 | { |
| 53 | - if (!$this->record->canView($this->getMember())) { |
|
| 53 | + if(!$this->record->canView($this->getMember())) { |
|
| 54 | 54 | return $this->message('You are not authorized to do that on this environment', 403); |
| 55 | 55 | } |
| 56 | - switch ($request->httpMethod()) { |
|
| 56 | + switch($request->httpMethod()) { |
|
| 57 | 57 | case 'GET': |
| 58 | 58 | return $this->getFetch($this->getRequest()->param('ID')); |
| 59 | 59 | case 'POST': |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | protected function getFetch($ID) |
| 71 | 71 | { |
| 72 | 72 | $ping = DNGitFetch::get()->byID($ID); |
| 73 | - if (!$ping) { |
|
| 73 | + if(!$ping) { |
|
| 74 | 74 | return $this->message('Fetch not found', 404); |
| 75 | 75 | } |
| 76 | 76 | $output = array( |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | $currentBuild = $environment->CurrentBuild(); |
| 32 | 32 | $currentSha = $currentBuild ? $currentBuild->SHA : '-'; |
| 33 | - if ($currentSha !== $options['sha']) { |
|
| 33 | + if($currentSha !== $options['sha']) { |
|
| 34 | 34 | $strategy->setChange('Code version', $currentSha, $options['sha']); |
| 35 | 35 | } |
| 36 | 36 | $strategy->setActionTitle('Confirm deployment'); |
@@ -71,53 +71,53 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | // Use a package generator if specified, otherwise run a direct deploy, which is the default behaviour |
| 73 | 73 | // if build_filename isn't specified |
| 74 | - if ($this->packageGenerator) { |
|
| 74 | + if($this->packageGenerator) { |
|
| 75 | 75 | $log->write(sprintf('Using package generator "%s"', get_class($this->packageGenerator))); |
| 76 | 76 | |
| 77 | 77 | try { |
| 78 | 78 | $args['build_filename'] = $this->packageGenerator->getPackageFilename($project->Name, $sha, $repository, $log); |
| 79 | - } catch (Exception $e) { |
|
| 79 | + } catch(Exception $e) { |
|
| 80 | 80 | $log->write($e->getMessage()); |
| 81 | 81 | throw $e; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - if (empty($args['build_filename'])) { |
|
| 84 | + if(empty($args['build_filename'])) { |
|
| 85 | 85 | throw new RuntimeException('Failed to generate package.'); |
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | $command = $this->getCommand('deploy', 'web', $environment, $args, $log); |
| 90 | - $command->run(function ($type, $buffer) use ($log) { |
|
| 90 | + $command->run(function($type, $buffer) use ($log) { |
|
| 91 | 91 | $log->write($buffer); |
| 92 | 92 | }); |
| 93 | 93 | |
| 94 | 94 | // Deployment cleanup. We assume it is always safe to run this at the end, regardless of the outcome. |
| 95 | 95 | $self = $this; |
| 96 | - $cleanupFn = function () use ($self, $environment, $args, $log) { |
|
| 96 | + $cleanupFn = function() use ($self, $environment, $args, $log) { |
|
| 97 | 97 | $command = $self->getCommand('deploy:cleanup', 'web', $environment, $args, $log); |
| 98 | - $command->run(function ($type, $buffer) use ($log) { |
|
| 98 | + $command->run(function($type, $buffer) use ($log) { |
|
| 99 | 99 | $log->write($buffer); |
| 100 | 100 | }); |
| 101 | 101 | |
| 102 | - if (!$command->isSuccessful()) { |
|
| 102 | + if(!$command->isSuccessful()) { |
|
| 103 | 103 | $this->extend('cleanupFailure', $environment, $sha, $log, $project); |
| 104 | 104 | $log->write('Warning: Cleanup failed, but fine to continue. Needs manual cleanup sometime.'); |
| 105 | 105 | } |
| 106 | 106 | }; |
| 107 | 107 | |
| 108 | 108 | // Once the deployment has run it's necessary to update the maintenance page status |
| 109 | - if (!empty($options['leaveMaintenancePage'])) { |
|
| 109 | + if(!empty($options['leaveMaintenancePage'])) { |
|
| 110 | 110 | $this->enableMaintenance($environment, $log, $project); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - if (!$command->isSuccessful()) { |
|
| 113 | + if(!$command->isSuccessful()) { |
|
| 114 | 114 | $cleanupFn(); |
| 115 | 115 | $this->extend('deployFailure', $environment, $sha, $log, $project); |
| 116 | 116 | throw new RuntimeException($command->getErrorOutput()); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // Check if maintenance page should be removed |
| 120 | - if (empty($options['leaveMaintenancePage'])) { |
|
| 120 | + if(empty($options['leaveMaintenancePage'])) { |
|
| 121 | 121 | $this->disableMaintenance($environment, $log, $project); |
| 122 | 122 | } |
| 123 | 123 | |
@@ -135,10 +135,10 @@ discard block |
||
| 135 | 135 | { |
| 136 | 136 | $name = $environment->getFullName(); |
| 137 | 137 | $command = $this->getCommand('maintenance:enable', 'web', $environment, null, $log); |
| 138 | - $command->run(function ($type, $buffer) use ($log) { |
|
| 138 | + $command->run(function($type, $buffer) use ($log) { |
|
| 139 | 139 | $log->write($buffer); |
| 140 | 140 | }); |
| 141 | - if (!$command->isSuccessful()) { |
|
| 141 | + if(!$command->isSuccessful()) { |
|
| 142 | 142 | $this->extend('maintenanceEnableFailure', $environment, $log); |
| 143 | 143 | throw new RuntimeException($command->getErrorOutput()); |
| 144 | 144 | } |
@@ -152,10 +152,10 @@ discard block |
||
| 152 | 152 | { |
| 153 | 153 | $name = $environment->getFullName(); |
| 154 | 154 | $command = $this->getCommand('maintenance:disable', 'web', $environment, null, $log); |
| 155 | - $command->run(function ($type, $buffer) use ($log) { |
|
| 155 | + $command->run(function($type, $buffer) use ($log) { |
|
| 156 | 156 | $log->write($buffer); |
| 157 | 157 | }); |
| 158 | - if (!$command->isSuccessful()) { |
|
| 158 | + if(!$command->isSuccessful()) { |
|
| 159 | 159 | $this->extend('maintenanceDisableFailure', $environment, $log); |
| 160 | 160 | throw new RuntimeException($command->getErrorOutput()); |
| 161 | 161 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | public function ping(DNEnvironment $environment, DeploynautLogFile $log, DNProject $project) |
| 169 | 169 | { |
| 170 | 170 | $command = $this->getCommand('deploy:check', 'web', $environment, null, $log); |
| 171 | - $command->run(function ($type, $buffer) use ($log) { |
|
| 171 | + $command->run(function($type, $buffer) use ($log) { |
|
| 172 | 172 | $log->write($buffer); |
| 173 | 173 | echo $buffer; |
| 174 | 174 | }); |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | public function dataTransfer(DNDataTransfer $dataTransfer, DeploynautLogFile $log) |
| 181 | 181 | { |
| 182 | - if ($dataTransfer->Direction == 'get') { |
|
| 182 | + if($dataTransfer->Direction == 'get') { |
|
| 183 | 183 | $this->dataTransferBackup($dataTransfer, $log); |
| 184 | 184 | } else { |
| 185 | 185 | $environment = $dataTransfer->Environment(); |
@@ -190,14 +190,14 @@ discard block |
||
| 190 | 190 | // extract the sspak contents, we'll need these so capistrano can restore that content |
| 191 | 191 | try { |
| 192 | 192 | $archive->extractArchive($workingDir); |
| 193 | - } catch (Exception $e) { |
|
| 193 | + } catch(Exception $e) { |
|
| 194 | 194 | $log->write($e->getMessage()); |
| 195 | 195 | throw new RuntimeException($e->getMessage()); |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | // validate the contents match the requested transfer mode |
| 199 | 199 | $result = $archive->validateArchiveContents($dataTransfer->Mode); |
| 200 | - if (!$result->valid()) { |
|
| 200 | + if(!$result->valid()) { |
|
| 201 | 201 | // do some cleaning, get rid of the extracted archive lying around |
| 202 | 202 | $process = new Process(sprintf('rm -rf %s', escapeshellarg($workingDir))); |
| 203 | 203 | $process->run(); |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | $name = $environment->getFullName(); |
| 228 | 228 | $env = $environment->Project()->getProcessEnv(); |
| 229 | 229 | |
| 230 | - if (!$args) { |
|
| 230 | + if(!$args) { |
|
| 231 | 231 | $args = array(); |
| 232 | 232 | } |
| 233 | 233 | $args['history_path'] = realpath(DEPLOYNAUT_LOG_PATH . '/'); |
@@ -235,9 +235,9 @@ discard block |
||
| 235 | 235 | // Inject env string directly into the command. |
| 236 | 236 | // Capistrano doesn't like the $process->setEnv($env) we'd normally do below. |
| 237 | 237 | $envString = ''; |
| 238 | - if (!empty($env)) { |
|
| 238 | + if(!empty($env)) { |
|
| 239 | 239 | $envString .= 'env '; |
| 240 | - foreach ($env as $key => $value) { |
|
| 240 | + foreach($env as $key => $value) { |
|
| 241 | 241 | $envString .= "$key=\"$value\" "; |
| 242 | 242 | } |
| 243 | 243 | } |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | $capTemplate |
| 252 | 252 | ); |
| 253 | 253 | |
| 254 | - if (defined('DEPLOYNAUT_CAPFILE')) { |
|
| 254 | + if(defined('DEPLOYNAUT_CAPFILE')) { |
|
| 255 | 255 | $capFile = DEPLOYNAUT_CAPFILE; |
| 256 | 256 | } else { |
| 257 | 257 | $capFile = ASSETS_PATH . '/Capfile'; |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | file_put_contents($capFile, $cap); |
| 260 | 260 | |
| 261 | 261 | $command = "{$envString}cap -f " . escapeshellarg($capFile) . " -vv $name $action ROLES=$roles"; |
| 262 | - foreach ($args as $argName => $argVal) { |
|
| 262 | + foreach($args as $argName => $argVal) { |
|
| 263 | 263 | $command .= ' -s ' . escapeshellarg($argName) . '=' . escapeshellarg($argVal); |
| 264 | 264 | } |
| 265 | 265 | |
@@ -298,13 +298,13 @@ discard block |
||
| 298 | 298 | $databasePath = $filepathBase . DIRECTORY_SEPARATOR . 'database.sql'; |
| 299 | 299 | |
| 300 | 300 | // Backup database |
| 301 | - if (in_array($dataTransfer->Mode, array('all', 'db'))) { |
|
| 301 | + if(in_array($dataTransfer->Mode, array('all', 'db'))) { |
|
| 302 | 302 | $log->write(sprintf('Backup of database from "%s" started', $name)); |
| 303 | 303 | $command = $this->getCommand('data:getdb', 'db', $environment, array('data_path' => $databasePath), $log); |
| 304 | - $command->run(function ($type, $buffer) use ($log) { |
|
| 304 | + $command->run(function($type, $buffer) use ($log) { |
|
| 305 | 305 | $log->write($buffer); |
| 306 | 306 | }); |
| 307 | - if (!$command->isSuccessful()) { |
|
| 307 | + if(!$command->isSuccessful()) { |
|
| 308 | 308 | $this->extend('dataTransferFailure', $environment, $log); |
| 309 | 309 | throw new RuntimeException($command->getErrorOutput()); |
| 310 | 310 | } |
@@ -312,13 +312,13 @@ discard block |
||
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | // Backup assets |
| 315 | - if (in_array($dataTransfer->Mode, array('all', 'assets'))) { |
|
| 315 | + if(in_array($dataTransfer->Mode, array('all', 'assets'))) { |
|
| 316 | 316 | $log->write(sprintf('Backup of assets from "%s" started', $name)); |
| 317 | 317 | $command = $this->getCommand('data:getassets', 'web', $environment, array('data_path' => $filepathBase), $log); |
| 318 | - $command->run(function ($type, $buffer) use ($log) { |
|
| 318 | + $command->run(function($type, $buffer) use ($log) { |
|
| 319 | 319 | $log->write($buffer); |
| 320 | 320 | }); |
| 321 | - if (!$command->isSuccessful()) { |
|
| 321 | + if(!$command->isSuccessful()) { |
|
| 322 | 322 | $this->extend('dataTransferFailure', $environment, $log); |
| 323 | 323 | throw new RuntimeException($command->getErrorOutput()); |
| 324 | 324 | } |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | try { |
| 332 | 332 | $dataArchive->attachFile($sspakFilepath, $dataTransfer); |
| 333 | 333 | $dataArchive->setArchiveFromFiles($filepathBase); |
| 334 | - } catch (Exception $e) { |
|
| 334 | + } catch(Exception $e) { |
|
| 335 | 335 | $log->write($e->getMessage()); |
| 336 | 336 | throw new RuntimeException($e->getMessage()); |
| 337 | 337 | } |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | // e.g. when just an assets backup has been requested and no database.sql exists. |
| 342 | 342 | $process = new Process(sprintf('rm -rf %s/assets && rm -f %s', $filepathBase, $databasePath)); |
| 343 | 343 | $process->run(); |
| 344 | - if (!$process->isSuccessful()) { |
|
| 344 | + if(!$process->isSuccessful()) { |
|
| 345 | 345 | $log->write('Could not delete temporary files'); |
| 346 | 346 | throw new RuntimeException($process->getErrorOutput()); |
| 347 | 347 | } |
@@ -358,10 +358,10 @@ discard block |
||
| 358 | 358 | { |
| 359 | 359 | $name = $environment->getFullName(); |
| 360 | 360 | $command = $this->getCommand('deploy:migrate', 'web', $environment, null, $log); |
| 361 | - $command->run(function ($type, $buffer) use ($log) { |
|
| 361 | + $command->run(function($type, $buffer) use ($log) { |
|
| 362 | 362 | $log->write($buffer); |
| 363 | 363 | }); |
| 364 | - if (!$command->isSuccessful()) { |
|
| 364 | + if(!$command->isSuccessful()) { |
|
| 365 | 365 | $log->write(sprintf('Rebuild of "%s" failed: %s', $name, $command->getErrorOutput())); |
| 366 | 366 | throw new RuntimeException($command->getErrorOutput()); |
| 367 | 367 | } |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | |
| 384 | 384 | // Rollback cleanup. |
| 385 | 385 | $self = $this; |
| 386 | - $cleanupFn = function () use ($self, $workingDir, $environment, $log) { |
|
| 386 | + $cleanupFn = function() use ($self, $workingDir, $environment, $log) { |
|
| 387 | 387 | // Rebuild makes sense even if failed - maybe we can at least partly recover. |
| 388 | 388 | $self->rebuild($environment, $log); |
| 389 | 389 | $process = new Process(sprintf('rm -rf %s', escapeshellarg($workingDir))); |
@@ -391,14 +391,14 @@ discard block |
||
| 391 | 391 | }; |
| 392 | 392 | |
| 393 | 393 | // Restore database into target environment |
| 394 | - if (in_array($dataTransfer->Mode, array('all', 'db'))) { |
|
| 394 | + if(in_array($dataTransfer->Mode, array('all', 'db'))) { |
|
| 395 | 395 | $log->write(sprintf('Restore of database to "%s" started', $name)); |
| 396 | 396 | $args = array('data_path' => $workingDir . DIRECTORY_SEPARATOR . 'database.sql'); |
| 397 | 397 | $command = $this->getCommand('data:pushdb', 'db', $environment, $args, $log); |
| 398 | - $command->run(function ($type, $buffer) use ($log) { |
|
| 398 | + $command->run(function($type, $buffer) use ($log) { |
|
| 399 | 399 | $log->write($buffer); |
| 400 | 400 | }); |
| 401 | - if (!$command->isSuccessful()) { |
|
| 401 | + if(!$command->isSuccessful()) { |
|
| 402 | 402 | $cleanupFn(); |
| 403 | 403 | $log->write(sprintf('Restore of database to "%s" failed: %s', $name, $command->getErrorOutput())); |
| 404 | 404 | $this->extend('dataTransferFailure', $environment, $log); |
@@ -408,14 +408,14 @@ discard block |
||
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | // Restore assets into target environment |
| 411 | - if (in_array($dataTransfer->Mode, array('all', 'assets'))) { |
|
| 411 | + if(in_array($dataTransfer->Mode, array('all', 'assets'))) { |
|
| 412 | 412 | $log->write(sprintf('Restore of assets to "%s" started', $name)); |
| 413 | 413 | $args = array('data_path' => $workingDir . DIRECTORY_SEPARATOR . 'assets'); |
| 414 | 414 | $command = $this->getCommand('data:pushassets', 'web', $environment, $args, $log); |
| 415 | - $command->run(function ($type, $buffer) use ($log) { |
|
| 415 | + $command->run(function($type, $buffer) use ($log) { |
|
| 416 | 416 | $log->write($buffer); |
| 417 | 417 | }); |
| 418 | - if (!$command->isSuccessful()) { |
|
| 418 | + if(!$command->isSuccessful()) { |
|
| 419 | 419 | $cleanupFn(); |
| 420 | 420 | $log->write(sprintf('Restore of assets to "%s" failed: %s', $name, $command->getErrorOutput())); |
| 421 | 421 | $this->extend('dataTransferFailure', $environment, $log); |
@@ -56,7 +56,7 @@ |
||
| 56 | 56 | $log->write("Well, that was a waste of time"); |
| 57 | 57 | |
| 58 | 58 | // Once the deployment has run it's necessary to update the maintenance page status |
| 59 | - if (!empty($options['leaveMaintenancePage'])) { |
|
| 59 | + if(!empty($options['leaveMaintenancePage'])) { |
|
| 60 | 60 | $this->enableMaintenance($environment, $log, $project); |
| 61 | 61 | } else { |
| 62 | 62 | // Remove maintenance page if we want it to |
@@ -141,10 +141,10 @@ discard block |
||
| 141 | 141 | public function getChangesModificationNeeded() |
| 142 | 142 | { |
| 143 | 143 | $filtered = []; |
| 144 | - foreach ($this->changes as $change => $details) { |
|
| 145 | - if (array_key_exists('description', $details)) { |
|
| 144 | + foreach($this->changes as $change => $details) { |
|
| 145 | + if(array_key_exists('description', $details)) { |
|
| 146 | 146 | $filtered[$change] = $details; |
| 147 | - } elseif ( |
|
| 147 | + } elseif( |
|
| 148 | 148 | (array_key_exists('from', $details) || array_key_exists('to', $details)) |
| 149 | 149 | && $details['from'] !== $details['to'] |
| 150 | 150 | ) { |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | public function getChange($key) |
| 178 | 178 | { |
| 179 | 179 | $changes = $this->getChanges(); |
| 180 | - if (array_key_exists($key, $changes)) { |
|
| 180 | + if(array_key_exists($key, $changes)) { |
|
| 181 | 181 | return new ArrayData($changes[$key]); |
| 182 | 182 | } |
| 183 | 183 | return null; |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | */ |
| 199 | 199 | public function getOption($option) |
| 200 | 200 | { |
| 201 | - if (!empty($this->options[$option])) { |
|
| 201 | + if(!empty($this->options[$option])) { |
|
| 202 | 202 | return $this->options[$option]; |
| 203 | 203 | } |
| 204 | 204 | } |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | DeploymentStrategy::WARNING_CODE => 1, |
| 244 | 244 | DeploymentStrategy::ERROR_CODE => 2 |
| 245 | 245 | ]; |
| 246 | - if ($map[$current] < $map[$code]) { |
|
| 246 | + if($map[$current] < $map[$code]) { |
|
| 247 | 247 | $this->setValidationCode($code); |
| 248 | 248 | } |
| 249 | 249 | } |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | ); |
| 275 | 275 | |
| 276 | 276 | $output = array(); |
| 277 | - foreach ($fields as $field) { |
|
| 277 | + foreach($fields as $field) { |
|
| 278 | 278 | $output[$field] = $this->$field; |
| 279 | 279 | } |
| 280 | 280 | return $output; |
@@ -318,8 +318,8 @@ discard block |
||
| 318 | 318 | 'messages' |
| 319 | 319 | ); |
| 320 | 320 | |
| 321 | - foreach ($fields as $field) { |
|
| 322 | - if (!empty($data[$field])) { |
|
| 321 | + foreach($fields as $field) { |
|
| 322 | + if(!empty($data[$field])) { |
|
| 323 | 323 | $this->$field = $data[$field]; |
| 324 | 324 | } |
| 325 | 325 | } |
@@ -54,14 +54,14 @@ |
||
| 54 | 54 | public function getPackageFilename($identifier, $sha, $repositoryDir, DeploynautLogFile $log) |
| 55 | 55 | { |
| 56 | 56 | // Fetch through the cache |
| 57 | - if ($this->cache) { |
|
| 57 | + if($this->cache) { |
|
| 58 | 58 | $identifier .= '-' . get_class($this) . '-' . $this->getIdentifier(); |
| 59 | 59 | return $this->cache->getPackageFilename($this, $identifier, $sha, $repositoryDir, $log); |
| 60 | 60 | |
| 61 | 61 | // Default, cacheless implementation |
| 62 | 62 | } else { |
| 63 | 63 | $filename = TEMP_FOLDER . '/' . $sha . '.tar.gz'; |
| 64 | - if ($this->generatePackage($sha, $repositoryDir, $filename, $log)) { |
|
| 64 | + if($this->generatePackage($sha, $repositoryDir, $filename, $log)) { |
|
| 65 | 65 | return $filename; |
| 66 | 66 | } |
| 67 | 67 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | public function generatePackage($sha, $baseDir, $outputFilename, DeploynautLogFile $log) |
| 40 | 40 | { |
| 41 | 41 | $tempPath = TEMP_FOLDER . "/" . str_replace(".tar.gz", "", basename($outputFilename)); |
| 42 | - if (!file_exists($tempPath)) { |
|
| 42 | + if(!file_exists($tempPath)) { |
|
| 43 | 43 | mkdir($tempPath); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | try { |
| 67 | 67 | $this->executeProcesses($processes, $log); |
| 68 | - } catch (Exception $e) { |
|
| 68 | + } catch(Exception $e) { |
|
| 69 | 69 | // Execute cleanup on failure |
| 70 | 70 | $this->executeProcesses($cleanup, $log); |
| 71 | 71 | throw $e; |
@@ -84,8 +84,8 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | protected function executeProcesses($processes, DeploynautLogFile $log) |
| 86 | 86 | { |
| 87 | - foreach ($processes as $process) { |
|
| 88 | - $process->mustRun(function ($type, $buffer) use ($log) { |
|
| 87 | + foreach($processes as $process) { |
|
| 88 | + $process->mustRun(function($type, $buffer) use ($log) { |
|
| 89 | 89 | $log->write($buffer); |
| 90 | 90 | }); |
| 91 | 91 | } |