@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | public function perform() { |
| 23 | - echo "[-] DataTransferJob starting" . PHP_EOL; |
|
| 23 | + echo "[-] DataTransferJob starting".PHP_EOL; |
|
| 24 | 24 | $log = new DeploynautLogFile($this->args['logfile']); |
| 25 | 25 | $dataTransfer = DNDataTransfer::get()->byID($this->args['dataTransferID']); |
| 26 | 26 | $environment = $dataTransfer->Environment(); |
@@ -64,16 +64,16 @@ discard block |
||
| 64 | 64 | $this->performBackup($backupDataTransfer, $log); |
| 65 | 65 | $environment->Backend()->dataTransfer($dataTransfer, $log); |
| 66 | 66 | } catch(Exception $e) { |
| 67 | - echo "[-] DataTransferJob failed" . PHP_EOL; |
|
| 67 | + echo "[-] DataTransferJob failed".PHP_EOL; |
|
| 68 | 68 | throw $e; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $this->updateStatus('Finished'); |
| 72 | - echo "[-] DataTransferJob finished" . PHP_EOL; |
|
| 72 | + echo "[-] DataTransferJob finished".PHP_EOL; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | protected function performBackup($backupDataTransfer, DeploynautLogFile $log) { |
| 76 | - if (!$backupDataTransfer) { |
|
| 76 | + if(!$backupDataTransfer) { |
|
| 77 | 77 | return false; |
| 78 | 78 | } |
| 79 | 79 | |
@@ -17,9 +17,9 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | public function alarmHandler() { |
| 19 | 19 | $sigFile = $this->args['sigFile']; |
| 20 | - if (file_exists($sigFile) && is_readable($sigFile) && is_writable($sigFile)) { |
|
| 20 | + if(file_exists($sigFile) && is_readable($sigFile) && is_writable($sigFile)) { |
|
| 21 | 21 | $signal = (int)file_get_contents($sigFile); |
| 22 | - if (is_int($signal) && in_array((int)$signal, [ |
|
| 22 | + if(is_int($signal) && in_array((int)$signal, [ |
|
| 23 | 23 | // The following signals are trapped by both Resque and Rainforest. |
| 24 | 24 | SIGTERM, |
| 25 | 25 | SIGINT, |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | SIGCONT |
| 31 | 31 | ])) { |
| 32 | 32 | echo sprintf( |
| 33 | - '[-] Signal "%s" received, delivering to own process group, PID "%s".' . PHP_EOL, |
|
| 33 | + '[-] Signal "%s" received, delivering to own process group, PID "%s".'.PHP_EOL, |
|
| 34 | 34 | $signal, |
| 35 | 35 | getmypid() |
| 36 | 36 | ); |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | // Dispatch to own process group. |
| 42 | 42 | $pgid = posix_getpgid(getmypid()); |
| 43 | - if ($pgid<=0) { |
|
| 43 | + if($pgid <= 0) { |
|
| 44 | 44 | echo sprintf( |
| 45 | - '[-] Unable to send signal to invalid PGID "%s".' . PHP_EOL, |
|
| 45 | + '[-] Unable to send signal to invalid PGID "%s".'.PHP_EOL, |
|
| 46 | 46 | $pgid |
| 47 | 47 | ); |
| 48 | 48 | } else { |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | posix_setsid(); |
| 62 | 62 | |
| 63 | 63 | if(function_exists('pcntl_alarm') && function_exists('pcntl_signal')) { |
| 64 | - if (!empty($this->args['sigFile'])) { |
|
| 65 | - echo sprintf('[-] Signal file requested, polling "%s".' . PHP_EOL, $this->args['sigFile']); |
|
| 64 | + if(!empty($this->args['sigFile'])) { |
|
| 65 | + echo sprintf('[-] Signal file requested, polling "%s".'.PHP_EOL, $this->args['sigFile']); |
|
| 66 | 66 | declare(ticks = 1); |
| 67 | 67 | pcntl_signal(SIGALRM, [$this, 'alarmHandler']); |
| 68 | 68 | pcntl_alarm(1); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | public function perform() { |
| 77 | - echo "[-] DeployJob starting" . PHP_EOL; |
|
| 77 | + echo "[-] DeployJob starting".PHP_EOL; |
|
| 78 | 78 | $log = new DeploynautLogFile($this->args['logfile']); |
| 79 | 79 | |
| 80 | 80 | $deployment = DNDeployment::get()->byID($this->args['deploymentID']); |
@@ -127,12 +127,12 @@ discard block |
||
| 127 | 127 | ); |
| 128 | 128 | } catch(Exception $e) { |
| 129 | 129 | // DeploynautJob will automatically trigger onFailure. |
| 130 | - echo "[-] DeployJob failed" . PHP_EOL; |
|
| 130 | + echo "[-] DeployJob failed".PHP_EOL; |
|
| 131 | 131 | throw $e; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | $this->updateStatus(DNDeployment::TR_COMPLETE); |
| 135 | - echo "[-] DeployJob finished" . PHP_EOL; |
|
| 135 | + echo "[-] DeployJob finished".PHP_EOL; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | public function onFailure(Exception $exception) { |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | protected function performBackup($backupDataTransfer, DeploynautLogFile $log) { |
| 143 | - if (!$backupDataTransfer) { |
|
| 143 | + if(!$backupDataTransfer) { |
|
| 144 | 144 | return false; |
| 145 | 145 | } |
| 146 | 146 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | try { |
| 73 | 73 | $args['build_filename'] = $this->packageGenerator->getPackageFilename($project->Name, $sha, $repository, $log); |
| 74 | - } catch (Exception $e) { |
|
| 74 | + } catch(Exception $e) { |
|
| 75 | 75 | $log->write($e->getMessage()); |
| 76 | 76 | throw $e; |
| 77 | 77 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | $this->extend('deployFailure', $environment, $sha, $log, $project); |
| 111 | 111 | |
| 112 | 112 | $currentBuild = $environment->CurrentBuild(); |
| 113 | - if (empty($currentBuild) || (!empty($options['no_rollback']) && $options['no_rollback'] !== 'false')) { |
|
| 113 | + if(empty($currentBuild) || (!empty($options['no_rollback']) && $options['no_rollback'] !== 'false')) { |
|
| 114 | 114 | throw new RuntimeException($command->getErrorOutput()); |
| 115 | 115 | } |
| 116 | 116 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | // as deploying removes .htaccess |
| 127 | 127 | $this->enableMaintenance($environment, $log, $project); |
| 128 | 128 | |
| 129 | - if (!$command->isSuccessful() || !$this->smokeTest($environment, $log)) { |
|
| 129 | + if(!$command->isSuccessful() || !$this->smokeTest($environment, $log)) { |
|
| 130 | 130 | $this->extend('deployRollbackFailure', $environment, $currentBuild->SHA, $log, $project); |
| 131 | 131 | $log->write('Rollback failed'); |
| 132 | 132 | throw new RuntimeException($command->getErrorOutput()); |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | // Rolling back means the rollback succeeded, but ultimately the deployment |
| 144 | 144 | // has failed. Throw an exception so the job is marked as failed accordingly. |
| 145 | - if ($rolledBack === true) { |
|
| 145 | + if($rolledBack === true) { |
|
| 146 | 146 | throw new RuntimeException('Rollback successful'); |
| 147 | 147 | } |
| 148 | 148 | |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | } else { |
| 214 | 214 | $environment = $dataTransfer->Environment(); |
| 215 | 215 | $project = $environment->Project(); |
| 216 | - $workingDir = TEMP_FOLDER . DIRECTORY_SEPARATOR . 'deploynaut-transfer-' . $dataTransfer->ID; |
|
| 216 | + $workingDir = TEMP_FOLDER.DIRECTORY_SEPARATOR.'deploynaut-transfer-'.$dataTransfer->ID; |
|
| 217 | 217 | $archive = $dataTransfer->DataArchive(); |
| 218 | 218 | |
| 219 | 219 | // extract the sspak contents, we'll need these so capistrano can restore that content |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | if(!$args) { |
| 260 | 260 | $args = array(); |
| 261 | 261 | } |
| 262 | - $args['history_path'] = realpath(DEPLOYNAUT_LOG_PATH . '/'); |
|
| 262 | + $args['history_path'] = realpath(DEPLOYNAUT_LOG_PATH.'/'); |
|
| 263 | 263 | $args['environment_id'] = $environment->ID; |
| 264 | 264 | |
| 265 | 265 | // Inject env string directly into the command. |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | |
| 275 | 275 | $data = DNData::inst(); |
| 276 | 276 | // Generate a capfile from a template |
| 277 | - $capTemplate = file_get_contents(BASE_PATH . '/deploynaut/Capfile.template'); |
|
| 277 | + $capTemplate = file_get_contents(BASE_PATH.'/deploynaut/Capfile.template'); |
|
| 278 | 278 | $cap = str_replace( |
| 279 | 279 | array('<config root>', '<ssh key>', '<base path>'), |
| 280 | 280 | array($data->getEnvironmentDir(), DEPLOYNAUT_SSH_KEY, BASE_PATH), |
@@ -284,13 +284,13 @@ discard block |
||
| 284 | 284 | if(defined('DEPLOYNAUT_CAPFILE')) { |
| 285 | 285 | $capFile = DEPLOYNAUT_CAPFILE; |
| 286 | 286 | } else { |
| 287 | - $capFile = ASSETS_PATH . '/Capfile'; |
|
| 287 | + $capFile = ASSETS_PATH.'/Capfile'; |
|
| 288 | 288 | } |
| 289 | 289 | file_put_contents($capFile, $cap); |
| 290 | 290 | |
| 291 | - $command = "{$envString}cap -f " . escapeshellarg($capFile) . " -vv $name $action ROLES=$roles"; |
|
| 291 | + $command = "{$envString}cap -f ".escapeshellarg($capFile)." -vv $name $action ROLES=$roles"; |
|
| 292 | 292 | foreach($args as $argName => $argVal) { |
| 293 | - $command .= ' -s ' . escapeshellarg($argName) . '=' . escapeshellarg($argVal); |
|
| 293 | + $command .= ' -s '.escapeshellarg($argName).'='.escapeshellarg($argVal); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | $log->write(sprintf('Running command: %s', $command)); |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | $filepathBase = $dataArchive->generateFilepath($dataTransfer); |
| 325 | 325 | mkdir($filepathBase, 0700, true); |
| 326 | 326 | |
| 327 | - $databasePath = $filepathBase . DIRECTORY_SEPARATOR . 'database.sql'; |
|
| 327 | + $databasePath = $filepathBase.DIRECTORY_SEPARATOR.'database.sql'; |
|
| 328 | 328 | |
| 329 | 329 | // Backup database |
| 330 | 330 | if(in_array($dataTransfer->Mode, array('all', 'db'))) { |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | $log->write('Creating sspak...'); |
| 363 | 363 | |
| 364 | 364 | $sspakFilename = sprintf('%s.sspak', $dataArchive->generateFilename($dataTransfer)); |
| 365 | - $sspakFilepath = $filepathBase . DIRECTORY_SEPARATOR . $sspakFilename; |
|
| 365 | + $sspakFilepath = $filepathBase.DIRECTORY_SEPARATOR.$sspakFilename; |
|
| 366 | 366 | |
| 367 | 367 | try { |
| 368 | 368 | $dataArchive->attachFile($sspakFilepath, $dataTransfer); |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | // Restore database into target environment |
| 430 | 430 | if(in_array($dataTransfer->Mode, array('all', 'db'))) { |
| 431 | 431 | $log->write(sprintf('Restore of database to "%s" started', $name)); |
| 432 | - $args = array('data_path' => $workingDir . DIRECTORY_SEPARATOR . 'database.sql'); |
|
| 432 | + $args = array('data_path' => $workingDir.DIRECTORY_SEPARATOR.'database.sql'); |
|
| 433 | 433 | $command = $this->getCommand('data:pushdb', 'db', $environment, $args, $log); |
| 434 | 434 | $command->run(function($type, $buffer) use($log) { |
| 435 | 435 | $log->write($buffer); |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | // Restore assets into target environment |
| 447 | 447 | if(in_array($dataTransfer->Mode, array('all', 'assets'))) { |
| 448 | 448 | $log->write(sprintf('Restore of assets to "%s" started', $name)); |
| 449 | - $args = array('data_path' => $workingDir . DIRECTORY_SEPARATOR . 'assets'); |
|
| 449 | + $args = array('data_path' => $workingDir.DIRECTORY_SEPARATOR.'assets'); |
|
| 450 | 450 | $command = $this->getCommand('data:pushassets', 'web', $environment, $args, $log); |
| 451 | 451 | $command->run(function($type, $buffer) use($log) { |
| 452 | 452 | $log->write($buffer); |
@@ -527,17 +527,17 @@ discard block |
||
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | // Produce an informational ticker roughly every $tick |
| 530 | - if (time() > $infoTick) { |
|
| 530 | + if(time() > $infoTick) { |
|
| 531 | 531 | $message = []; |
| 532 | 532 | |
| 533 | 533 | // Collect status information from different sources. |
| 534 | - if ($status) { |
|
| 534 | + if($status) { |
|
| 535 | 535 | $message[] = sprintf('HTTP status code is %s', $status); |
| 536 | 536 | } |
| 537 | - if (!$response) { |
|
| 537 | + if(!$response) { |
|
| 538 | 538 | $message[] = 'response is empty'; |
| 539 | 539 | } |
| 540 | - if ($error = curl_error($ch)) { |
|
| 540 | + if($error = curl_error($ch)) { |
|
| 541 | 541 | $message[] = sprintf('request error: %s', $error); |
| 542 | 542 | } |
| 543 | 543 | |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | * |
| 47 | 47 | * @param \SS_HTTPRequest $request |
| 48 | 48 | * |
| 49 | - * @return \HTMLText|\SS_HTTPResponse |
|
| 49 | + * @return SS_HTTPResponse|null |
|
| 50 | 50 | */ |
| 51 | 51 | public function index(\SS_HTTPRequest $request) { |
| 52 | 52 | return $this->redirect(\Controller::join_links($this->Link(), 'history'), 302); |
@@ -41,13 +41,13 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | $this->project = $this->getCurrentProject(); |
| 43 | 43 | |
| 44 | - if (!$this->project) { |
|
| 44 | + if(!$this->project) { |
|
| 45 | 45 | return $this->project404Response(); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | // Performs canView permission check by limiting visible projects |
| 49 | 49 | $this->environment = $this->getCurrentEnvironment($this->project); |
| 50 | - if (!$this->environment) { |
|
| 50 | + if(!$this->environment) { |
|
| 51 | 51 | return $this->environment404Response(); |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -68,19 +68,19 @@ discard block |
||
| 68 | 68 | $data = []; |
| 69 | 69 | $list = $this->DeployHistory(); |
| 70 | 70 | $page = $request->getVar('page') ?: 1; |
| 71 | - if ($page > $list->TotalPages()) { |
|
| 71 | + if($page > $list->TotalPages()) { |
|
| 72 | 72 | $page = 1; |
| 73 | 73 | } |
| 74 | - if ($page < 1) { |
|
| 74 | + if($page < 1) { |
|
| 75 | 75 | $page = 1; |
| 76 | 76 | } |
| 77 | 77 | $start = ($page - 1) * $list->getPageLength(); |
| 78 | - $list->setPageStart((int) $start); |
|
| 79 | - if (empty($list)) { |
|
| 78 | + $list->setPageStart((int)$start); |
|
| 79 | + if(empty($list)) { |
|
| 80 | 80 | return $this->getAPIResponse(['list' => []], 200); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - foreach ($list as $deployment) { |
|
| 83 | + foreach($list as $deployment) { |
|
| 84 | 84 | $data[] = $this->getDeploymentData($deployment); |
| 85 | 85 | } |
| 86 | 86 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | public function currentbuild(SS_HTTPRequest $request) { |
| 100 | 100 | $currentBuild = $this->environment->CurrentBuild(); |
| 101 | - if (!$currentBuild) { |
|
| 101 | + if(!$currentBuild) { |
|
| 102 | 102 | return $this->getAPIResponse(['deployment' => []], 200); |
| 103 | 103 | } |
| 104 | 104 | return $this->getAPIResponse(['deployment' => $this->getDeploymentData($currentBuild)], 200); |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | public function show(SS_HTTPRequest $request) { |
| 112 | 112 | $deployment = DNDeployment::get()->byId($request->param('ID')); |
| 113 | 113 | $errorResponse = $this->validateDeployments($deployment); |
| 114 | - if ($errorResponse instanceof \SS_HTTPResponse) { |
|
| 114 | + if($errorResponse instanceof \SS_HTTPResponse) { |
|
| 115 | 115 | return $errorResponse; |
| 116 | 116 | } |
| 117 | 117 | return $this->getAPIResponse(['deployment' => $this->getDeploymentData($deployment)], 200); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | public function log(SS_HTTPRequest $request) { |
| 125 | 125 | $deployment = DNDeployment::get()->byId($request->param('ID')); |
| 126 | 126 | $errorResponse = $this->validateDeployments($deployment); |
| 127 | - if ($errorResponse instanceof \SS_HTTPResponse) { |
|
| 127 | + if($errorResponse instanceof \SS_HTTPResponse) { |
|
| 128 | 128 | return $errorResponse; |
| 129 | 129 | } |
| 130 | 130 | $log = $deployment->log(); |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | public function start(SS_HTTPRequest $request) { |
| 142 | 142 | $this->checkSecurityToken(); |
| 143 | 143 | |
| 144 | - if (!$this->environment->canDeploy(Member::currentUser())) { |
|
| 144 | + if(!$this->environment->canDeploy(Member::currentUser())) { |
|
| 145 | 145 | return $this->getAPIResponse(['message' => 'You are not authorised to deploy this environment'], 403); |
| 146 | 146 | } |
| 147 | 147 | |
@@ -197,12 +197,12 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | $deployer = $deployment->Deployer(); |
| 199 | 199 | $deployerData = null; |
| 200 | - if ($deployer && $deployer->exists()) { |
|
| 200 | + if($deployer && $deployer->exists()) { |
|
| 201 | 201 | $deployerData = $this->getStackMemberData($deployer); |
| 202 | 202 | } |
| 203 | 203 | $approver = $deployment->Approver(); |
| 204 | 204 | $approverData = null; |
| 205 | - if ($approver && $approver->exists()) { |
|
| 205 | + if($approver && $approver->exists()) { |
|
| 206 | 206 | $approverData = $this->getStackMemberData($approver); |
| 207 | 207 | } |
| 208 | 208 | |
@@ -236,8 +236,8 @@ discard block |
||
| 236 | 236 | $stackMembers = $this->project->listMembers(); |
| 237 | 237 | $role = null; |
| 238 | 238 | |
| 239 | - foreach ($stackMembers as $stackMember) { |
|
| 240 | - if ($stackMember['MemberID'] !== $member->ID) { |
|
| 239 | + foreach($stackMembers as $stackMember) { |
|
| 240 | + if($stackMember['MemberID'] !== $member->ID) { |
|
| 241 | 241 | continue; |
| 242 | 242 | } |
| 243 | 243 | |
@@ -261,10 +261,10 @@ discard block |
||
| 261 | 261 | * @return null|SS_HTTPResponse |
| 262 | 262 | */ |
| 263 | 263 | protected function validateDeployments(\DNDeployment $deployment) { |
| 264 | - if (!$deployment || !$deployment->exists()) { |
|
| 264 | + if(!$deployment || !$deployment->exists()) { |
|
| 265 | 265 | return $this->getAPIResponse(['message' => 'This deployment does not exist'], 404); |
| 266 | 266 | } |
| 267 | - if (!$deployment->canView()) { |
|
| 267 | + if(!$deployment->canView()) { |
|
| 268 | 268 | return $this->getAPIResponse(['message' => 'You are not authorised to view this deployment'], 403); |
| 269 | 269 | } |
| 270 | 270 | return null; |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * |
| 48 | 48 | * @param \SS_HTTPRequest $request |
| 49 | 49 | * |
| 50 | - * @return \HTMLText|\SS_HTTPResponse |
|
| 50 | + * @return SS_HTTPResponse|null |
|
| 51 | 51 | */ |
| 52 | 52 | public function index(\SS_HTTPRequest $request) { |
| 53 | 53 | return $this->redirect(\Controller::join_links($this->Link(), 'show'), 302); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | /** |
| 73 | 73 | * @param SS_HTTPRequest $request |
| 74 | 74 | * |
| 75 | - * @return string |
|
| 75 | + * @return SS_HTTPResponse |
|
| 76 | 76 | */ |
| 77 | 77 | public function show(\SS_HTTPRequest $request) { |
| 78 | 78 | |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
| 169 | - * @param $project |
|
| 169 | + * @param DNProject $project |
|
| 170 | 170 | * |
| 171 | 171 | * @return array |
| 172 | 172 | */ |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
| 185 | - * @param $project |
|
| 185 | + * @param DNProject $project |
|
| 186 | 186 | * |
| 187 | 187 | * @return array |
| 188 | 188 | */ |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |
| 201 | - * @param $project |
|
| 201 | + * @param DNProject $project |
|
| 202 | 202 | * |
| 203 | 203 | * @return array |
| 204 | 204 | */ |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | $this->project = $this->getCurrentProject(); |
| 40 | 40 | |
| 41 | - if (!$this->project) { |
|
| 41 | + if(!$this->project) { |
|
| 42 | 42 | return $this->project404Response(); |
| 43 | 43 | } |
| 44 | 44 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @return SS_HTTPResponse |
| 59 | 59 | */ |
| 60 | 60 | public function update(SS_HTTPRequest $request) { |
| 61 | - switch ($request->httpMethod()) { |
|
| 61 | + switch($request->httpMethod()) { |
|
| 62 | 62 | case 'POST': |
| 63 | 63 | $this->checkSecurityToken(); |
| 64 | 64 | return $this->createUpdate(); |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | // @todo: the original was a tree that was keyed by environment, the |
| 96 | 96 | // front-end dropdown needs to be changed to support that. brrrr. |
| 97 | 97 | $prevDeploys = []; |
| 98 | - foreach ($this->getGitPrevDeploys($this->project) as $env) { |
|
| 99 | - foreach ($env as $deploy) { |
|
| 98 | + foreach($this->getGitPrevDeploys($this->project) as $env) { |
|
| 99 | + foreach($env as $deploy) { |
|
| 100 | 100 | $prevDeploys[] = $deploy; |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -132,8 +132,8 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | protected function getUpdateStatus($ID) { |
| 134 | 134 | $ping = DNGitFetch::get()->byID($ID); |
| 135 | - if (!$ping) { |
|
| 136 | - return $this->getAPIResponse(['message' => 'GIT update (' . $ID . ') not found'], 404); |
|
| 135 | + if(!$ping) { |
|
| 136 | + return $this->getAPIResponse(['message' => 'GIT update ('.$ID.') not found'], 404); |
|
| 137 | 137 | } |
| 138 | 138 | $output = [ |
| 139 | 139 | 'id' => $ID, |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | $fetch->write(); |
| 155 | 155 | $fetch->start(); |
| 156 | 156 | |
| 157 | - $location = Director::absoluteBaseURL() . $this->Link() . '/update/' . $fetch->ID; |
|
| 157 | + $location = Director::absoluteBaseURL().$this->Link().'/update/'.$fetch->ID; |
|
| 158 | 158 | $output = [ |
| 159 | 159 | 'message' => 'git fetch has been queued', |
| 160 | 160 | 'id' => $fetch->ID, |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | protected function getGitBranches($project) { |
| 175 | 175 | $branches = []; |
| 176 | - foreach ($project->DNBranchList() as $branch) { |
|
| 176 | + foreach($project->DNBranchList() as $branch) { |
|
| 177 | 177 | $branches[] = [ |
| 178 | 178 | 'key' => $branch->SHA(), |
| 179 | 179 | 'value' => $branch->Name(), |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | protected function getGitTags($project) { |
| 191 | 191 | $tags = []; |
| 192 | - foreach ($project->DNTagList()->setLimit(null) as $tag) { |
|
| 192 | + foreach($project->DNTagList()->setLimit(null) as $tag) { |
|
| 193 | 193 | $tags[] = [ |
| 194 | 194 | 'key' => $tag->SHA(), |
| 195 | 195 | 'value' => $tag->Name(), |
@@ -205,14 +205,14 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | protected function getGitPrevDeploys($project) { |
| 207 | 207 | $redeploy = []; |
| 208 | - foreach ($project->DNEnvironmentList() as $dnEnvironment) { |
|
| 208 | + foreach($project->DNEnvironmentList() as $dnEnvironment) { |
|
| 209 | 209 | $envName = $dnEnvironment->Name; |
| 210 | 210 | $perEnvDeploys = []; |
| 211 | - foreach ($dnEnvironment->DeployHistory() as $deploy) { |
|
| 211 | + foreach($dnEnvironment->DeployHistory() as $deploy) { |
|
| 212 | 212 | $sha = $deploy->SHA; |
| 213 | 213 | |
| 214 | 214 | // Check if exists to make sure the newest deployment date is used. |
| 215 | - if (!isset($perEnvDeploys[$sha])) { |
|
| 215 | + if(!isset($perEnvDeploys[$sha])) { |
|
| 216 | 216 | $pastValue = sprintf( |
| 217 | 217 | "%s (deployed %s)", |
| 218 | 218 | substr($sha, 0, 8), |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | ]; |
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | - if (!empty($perEnvDeploys)) { |
|
| 227 | + if(!empty($perEnvDeploys)) { |
|
| 228 | 228 | $redeploy[$envName] = array_values($perEnvDeploys); |
| 229 | 229 | } |
| 230 | 230 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | public function getModel($name) { |
| 19 | 19 | $deployment = $this->getDeployment(); |
| 20 | - if (!$deployment) { |
|
| 20 | + if(!$deployment) { |
|
| 21 | 21 | return []; |
| 22 | 22 | } |
| 23 | 23 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | public function getDeployment() { |
| 30 | 30 | $id = $this->request->param('Id'); |
| 31 | 31 | $deployment = DNDeployment::get()->byId($id); |
| 32 | - if (!$deployment || !$deployment->exists()) { |
|
| 32 | + if(!$deployment || !$deployment->exists()) { |
|
| 33 | 33 | return false; |
| 34 | 34 | } |
| 35 | 35 | return $deployment; |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | public function apply(SS_HTTPRequest $request) { |
| 39 | 39 | $this->checkSecurityToken(); |
| 40 | 40 | $response = $this->checkRequest(); |
| 41 | - if ($response instanceof SS_HTTPResponse) { |
|
| 41 | + if($response instanceof SS_HTTPResponse) { |
|
| 42 | 42 | return $response; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | public function canApply(SS_HTTPRequest $request) { |
| 53 | 53 | $this->checkSecurityToken(); |
| 54 | 54 | $response = $this->checkRequest(); |
| 55 | - if ($response instanceof SS_HTTPResponse) { |
|
| 55 | + if($response instanceof SS_HTTPResponse) { |
|
| 56 | 56 | return $response; |
| 57 | 57 | } |
| 58 | 58 | |
@@ -63,17 +63,17 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | protected function checkRequest() { |
| 65 | 65 | $project = $this->getCurrentProject(); |
| 66 | - if (!$project) { |
|
| 66 | + if(!$project) { |
|
| 67 | 67 | return $this->project404Response(); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | $env = $this->getCurrentEnvironment($project); |
| 71 | - if (!$env) { |
|
| 71 | + if(!$env) { |
|
| 72 | 72 | return $this->environment404Response(); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | $deployment = $this->getDeployment(); |
| 76 | - if (!$deployment) { |
|
| 76 | + if(!$deployment) { |
|
| 77 | 77 | return new SS_HTTPResponse('Deployment not found', 404); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | protected function getMachine() { |
| 84 | 84 | $deployment = $this->getDeployment(); |
| 85 | - if (!$deployment) { |
|
| 85 | + if(!$deployment) { |
|
| 86 | 86 | return null; |
| 87 | 87 | } |
| 88 | 88 | |
@@ -94,10 +94,10 @@ discard block |
||
| 94 | 94 | // It gives a chance to perform a dry-run, and reject the transition, for example |
| 95 | 95 | // in case the user is unauthorised. |
| 96 | 96 | 'finite.test_transition', |
| 97 | - function (Finite\Event\TransitionEvent $e) use ($project) { |
|
| 97 | + function(Finite\Event\TransitionEvent $e) use ($project) { |
|
| 98 | 98 | $code = null; |
| 99 | 99 | |
| 100 | - switch ($e->getTransition()->getName()) { |
|
| 100 | + switch($e->getTransition()->getName()) { |
|
| 101 | 101 | case DNDeployment::TR_SUBMIT: |
| 102 | 102 | $code = self::ALLOW_DNDEPLOYMENT_SUBMIT; |
| 103 | 103 | break; |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | break; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - if (!$code || !$project->allowed($code)) { |
|
| 109 | + if(!$code || !$project->allowed($code)) { |
|
| 110 | 110 | $e->reject(); |
| 111 | 111 | } |
| 112 | 112 | } |
@@ -37,13 +37,13 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | $this->project = $this->getCurrentProject(); |
| 39 | 39 | |
| 40 | - if (!$this->project) { |
|
| 40 | + if(!$this->project) { |
|
| 41 | 41 | return $this->project404Response(); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // Performs canView permission check by limiting visible projects |
| 45 | 45 | $this->environment = $this->getCurrentEnvironment($this->project); |
| 46 | - if (!$this->environment) { |
|
| 46 | + if(!$this->environment) { |
|
| 47 | 47 | return $this->environment404Response(); |
| 48 | 48 | } |
| 49 | 49 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function deploysummary(SS_HTTPRequest $request) { |
| 68 | 68 | |
| 69 | - if (strtolower($request->httpMethod()) !== 'post') { |
|
| 69 | + if(strtolower($request->httpMethod()) !== 'post') { |
|
| 70 | 70 | return $this->getAPIResponse(['message' => 'Method not allowed, requires POST'], 405); |
| 71 | 71 | } |
| 72 | 72 | $this->checkSecurityToken(); |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | $data = $strategy->toArray(); |
| 82 | 82 | |
| 83 | 83 | $interface = $this->project->getRepositoryInterface(); |
| 84 | - if ($this->canCompareCodeVersions($interface, $data['changes'])) { |
|
| 84 | + if($this->canCompareCodeVersions($interface, $data['changes'])) { |
|
| 85 | 85 | $compareurl = sprintf( |
| 86 | 86 | '%s/compare/%s...%s', |
| 87 | 87 | $interface->URL, |
@@ -118,20 +118,20 @@ discard block |
||
| 118 | 118 | * |
| 119 | 119 | */ |
| 120 | 120 | protected function canCompareCodeVersions(\ArrayData $interface, $changes) { |
| 121 | - if (empty($changes['Code version'])) { |
|
| 121 | + if(empty($changes['Code version'])) { |
|
| 122 | 122 | return false; |
| 123 | 123 | } |
| 124 | 124 | $codeVersion = ['Code version']; |
| 125 | - if (empty($interface)) { |
|
| 125 | + if(empty($interface)) { |
|
| 126 | 126 | return false; |
| 127 | 127 | } |
| 128 | - if (empty($interface->URL)) { |
|
| 128 | + if(empty($interface->URL)) { |
|
| 129 | 129 | return false; |
| 130 | 130 | } |
| 131 | - if (empty($codeVersion['from']) || empty($codeVersion['to'])) { |
|
| 131 | + if(empty($codeVersion['from']) || empty($codeVersion['to'])) { |
|
| 132 | 132 | return false; |
| 133 | 133 | } |
| 134 | - if (strlen($codeVersion['from']) !== 40 || strlen($codeVersion['to']) !== 40) { |
|
| 134 | + if(strlen($codeVersion['from']) !== 40 || strlen($codeVersion['to']) !== 40) { |
|
| 135 | 135 | return false; |
| 136 | 136 | } |
| 137 | 137 | return true; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function asJSONValidatorErrors($code, $validatorErrors) { |
| 52 | 52 | $fieldErrors = []; |
| 53 | - foreach ($validatorErrors as $error) { |
|
| 53 | + foreach($validatorErrors as $error) { |
|
| 54 | 54 | $fieldErrors[$error['fieldName']] = $error['message']; |
| 55 | 55 | } |
| 56 | 56 | return $this->asJSONFormFieldErrors($code, $fieldErrors); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | // To get around that, upon spotting an active redirect, we change the response code to 200, |
| 96 | 96 | // and move the redirect into the "RedirectTo" field in the JSON response. Frontend can |
| 97 | 97 | // then interpret this and trigger a redirect. |
| 98 | - if ($this->redirectedTo()) { |
|
| 98 | + if($this->redirectedTo()) { |
|
| 99 | 99 | $data['RedirectTo'] = $this->response->getHeader('Location'); |
| 100 | 100 | // Pop off the header - we are no longer redirecting via the usual mechanism. |
| 101 | 101 | $this->response->removeHeader('Location'); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | protected function checkSecurityToken() { |
| 130 | 130 | $securityToken = $this->getSecurityToken(); |
| 131 | - if (!$securityToken->check($this->request->postVar(self::SECURITY_TOKEN_NAME))) { |
|
| 131 | + if(!$securityToken->check($this->request->postVar(self::SECURITY_TOKEN_NAME))) { |
|
| 132 | 132 | $this->httpError(403, 'Invalid security token, try reloading the page.'); |
| 133 | 133 | } |
| 134 | 134 | } |
@@ -163,8 +163,8 @@ discard block |
||
| 163 | 163 | * @return string|array |
| 164 | 164 | */ |
| 165 | 165 | protected function trimWhitespace($val) { |
| 166 | - if (is_array($val)) { |
|
| 167 | - foreach ($val as $k => $v) { |
|
| 166 | + if(is_array($val)) { |
|
| 167 | + foreach($val as $k => $v) { |
|
| 168 | 168 | $val[$k] = $this->trimWhitespace($v); |
| 169 | 169 | } |
| 170 | 170 | return $val; |
@@ -180,8 +180,8 @@ discard block |
||
| 180 | 180 | * @return string|array |
| 181 | 181 | */ |
| 182 | 182 | protected function stripNonPrintables($val) { |
| 183 | - if (is_array($val)) { |
|
| 184 | - foreach ($val as $k => $v) { |
|
| 183 | + if(is_array($val)) { |
|
| 184 | + foreach($val as $k => $v) { |
|
| 185 | 185 | $val[$k] = $this->stripNonPrintables($v); |
| 186 | 186 | } |
| 187 | 187 | return $val; |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | public function init() { |
| 20 | 20 | parent::init(); |
| 21 | 21 | $this->project = $this->getCurrentProject(); |
| 22 | - if (!$this->project) { |
|
| 22 | + if(!$this->project) { |
|
| 23 | 23 | return $this->project404Response(); |
| 24 | 24 | } |
| 25 | 25 | // Performs canView permission check by limiting visible projects |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @return \HTMLText|\SS_HTTPResponse |
| 34 | 34 | */ |
| 35 | 35 | public function index(\SS_HTTPRequest $request) { |
| 36 | - if (!$this->environment) { |
|
| 36 | + if(!$this->environment) { |
|
| 37 | 37 | return $this->environment404Response(); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -63,9 +63,9 @@ discard block |
||
| 63 | 63 | $base = Director::absoluteBaseURL(); |
| 64 | 64 | return [ |
| 65 | 65 | 'dispatchers' => [ |
| 66 | - 'git' => $base . $this->getCurrentProject()->Link('git'), |
|
| 67 | - 'plan' => $base . $this->getCurrentEnvironment()->Link('plan'), |
|
| 68 | - 'deploys' => $base . $this->getCurrentEnvironment()->Link('deploys') |
|
| 66 | + 'git' => $base.$this->getCurrentProject()->Link('git'), |
|
| 67 | + 'plan' => $base.$this->getCurrentEnvironment()->Link('plan'), |
|
| 68 | + 'deploys' => $base.$this->getCurrentEnvironment()->Link('deploys') |
|
| 69 | 69 | ], |
| 70 | 70 | 'api_auth' => [ |
| 71 | 71 | 'name' => $this->getSecurityToken()->getName(), |