@@ -10,7 +10,7 @@ |
||
10 | 10 | // This will ensure jobs can correctly clean themselves up on any type of failure |
11 | 11 | Resque_Event::listen('onFailure', function(Exception $exception, Resque_job $job) { |
12 | 12 | $inst = $job->getInstance(); |
13 | - if($inst instanceof DeploynautJobInterface) { |
|
13 | + if ($inst instanceof DeploynautJobInterface) { |
|
14 | 14 | $inst->onFailure($exception); |
15 | 15 | } |
16 | 16 | }); |
@@ -63,9 +63,9 @@ |
||
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(), |
@@ -96,7 +96,7 @@ |
||
96 | 96 | // It gives a chance to perform a dry-run, and reject the transition, for example |
97 | 97 | // in case the user is unauthorised. |
98 | 98 | 'finite.test_transition', |
99 | - function (Finite\Event\TransitionEvent $e) use ($project) { |
|
99 | + function(Finite\Event\TransitionEvent $e) use ($project) { |
|
100 | 100 | $code = null; |
101 | 101 | |
102 | 102 | switch ($e->getTransition()->getName()) { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | $currentBuild = $environment->CurrentBuild(); |
27 | 27 | $currentSha = $currentBuild ? $currentBuild->SHA : '-'; |
28 | - if($currentSha !== $options['sha']) { |
|
28 | + if ($currentSha !== $options['sha']) { |
|
29 | 29 | $strategy->setChange('Code version', $currentSha, $options['sha']); |
30 | 30 | } |
31 | 31 | $strategy->setActionTitle('Confirm deployment'); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | // Use a package generator if specified, otherwise run a direct deploy, which is the default behaviour |
68 | 68 | // if build_filename isn't specified |
69 | - if($this->packageGenerator) { |
|
69 | + if ($this->packageGenerator) { |
|
70 | 70 | $log->write(sprintf('Using package generator "%s"', get_class($this->packageGenerator))); |
71 | 71 | |
72 | 72 | try { |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | throw $e; |
77 | 77 | } |
78 | 78 | |
79 | - if(empty($args['build_filename'])) { |
|
79 | + if (empty($args['build_filename'])) { |
|
80 | 80 | throw new RuntimeException('Failed to generate package.'); |
81 | 81 | } |
82 | 82 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $log->write($buffer); |
95 | 95 | }); |
96 | 96 | |
97 | - if(!$command->isSuccessful()) { |
|
97 | + if (!$command->isSuccessful()) { |
|
98 | 98 | $self->extend('cleanupFailure', $environment, $sha, $log, $project); |
99 | 99 | $log->write('Warning: Cleanup failed, but fine to continue. Needs manual cleanup sometime.'); |
100 | 100 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | $this->enableMaintenance($environment, $log, $project); |
106 | 106 | |
107 | 107 | $rolledBack = null; |
108 | - if(!$command->isSuccessful() || !$this->smokeTest($environment, $log)) { |
|
108 | + if (!$command->isSuccessful() || !$this->smokeTest($environment, $log)) { |
|
109 | 109 | $cleanupFn(); |
110 | 110 | $this->extend('deployFailure', $environment, $sha, $log, $project); |
111 | 111 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | $command->run(function($type, $buffer) use($log) { |
172 | 172 | $log->write($buffer); |
173 | 173 | }); |
174 | - if(!$command->isSuccessful()) { |
|
174 | + if (!$command->isSuccessful()) { |
|
175 | 175 | $this->extend('maintenanceEnableFailure', $environment, $log); |
176 | 176 | throw new RuntimeException($command->getErrorOutput()); |
177 | 177 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | $command->run(function($type, $buffer) use($log) { |
188 | 188 | $log->write($buffer); |
189 | 189 | }); |
190 | - if(!$command->isSuccessful()) { |
|
190 | + if (!$command->isSuccessful()) { |
|
191 | 191 | $this->extend('maintenanceDisableFailure', $environment, $log); |
192 | 192 | throw new RuntimeException($command->getErrorOutput()); |
193 | 193 | } |
@@ -209,25 +209,25 @@ discard block |
||
209 | 209 | * @inheritdoc |
210 | 210 | */ |
211 | 211 | public function dataTransfer(DNDataTransfer $dataTransfer, DeploynautLogFile $log) { |
212 | - if($dataTransfer->Direction == 'get') { |
|
212 | + if ($dataTransfer->Direction == 'get') { |
|
213 | 213 | $this->dataTransferBackup($dataTransfer, $log); |
214 | 214 | } else { |
215 | 215 | $environment = $dataTransfer->Environment(); |
216 | 216 | $project = $environment->Project(); |
217 | - $workingDir = TEMP_FOLDER . DIRECTORY_SEPARATOR . 'deploynaut-transfer-' . $dataTransfer->ID; |
|
217 | + $workingDir = TEMP_FOLDER.DIRECTORY_SEPARATOR.'deploynaut-transfer-'.$dataTransfer->ID; |
|
218 | 218 | $archive = $dataTransfer->DataArchive(); |
219 | 219 | |
220 | 220 | // extract the sspak contents, we'll need these so capistrano can restore that content |
221 | 221 | try { |
222 | 222 | $archive->extractArchive($workingDir); |
223 | - } catch(Exception $e) { |
|
223 | + } catch (Exception $e) { |
|
224 | 224 | $log->write($e->getMessage()); |
225 | 225 | throw new RuntimeException($e->getMessage()); |
226 | 226 | } |
227 | 227 | |
228 | 228 | // validate the contents match the requested transfer mode |
229 | 229 | $result = $archive->validateArchiveContents($dataTransfer->Mode); |
230 | - if(!$result->valid()) { |
|
230 | + if (!$result->valid()) { |
|
231 | 231 | // do some cleaning, get rid of the extracted archive lying around |
232 | 232 | $process = new AbortableProcess(sprintf('rm -rf %s', escapeshellarg($workingDir))); |
233 | 233 | $process->setTimeout(120); |
@@ -257,41 +257,41 @@ discard block |
||
257 | 257 | $name = $environment->getFullName(); |
258 | 258 | $env = $environment->Project()->getProcessEnv(); |
259 | 259 | |
260 | - if(!$args) { |
|
260 | + if (!$args) { |
|
261 | 261 | $args = array(); |
262 | 262 | } |
263 | - $args['history_path'] = realpath(DEPLOYNAUT_LOG_PATH . '/'); |
|
263 | + $args['history_path'] = realpath(DEPLOYNAUT_LOG_PATH.'/'); |
|
264 | 264 | $args['environment_id'] = $environment->ID; |
265 | 265 | |
266 | 266 | // Inject env string directly into the command. |
267 | 267 | // Capistrano doesn't like the $process->setEnv($env) we'd normally do below. |
268 | 268 | $envString = ''; |
269 | - if(!empty($env)) { |
|
269 | + if (!empty($env)) { |
|
270 | 270 | $envString .= 'env '; |
271 | - foreach($env as $key => $value) { |
|
271 | + foreach ($env as $key => $value) { |
|
272 | 272 | $envString .= "$key=\"$value\" "; |
273 | 273 | } |
274 | 274 | } |
275 | 275 | |
276 | 276 | $data = DNData::inst(); |
277 | 277 | // Generate a capfile from a template |
278 | - $capTemplate = file_get_contents(BASE_PATH . '/deploynaut/Capfile.template'); |
|
278 | + $capTemplate = file_get_contents(BASE_PATH.'/deploynaut/Capfile.template'); |
|
279 | 279 | $cap = str_replace( |
280 | 280 | array('<config root>', '<ssh key>', '<base path>'), |
281 | 281 | array($data->getEnvironmentDir(), DEPLOYNAUT_SSH_KEY, BASE_PATH), |
282 | 282 | $capTemplate |
283 | 283 | ); |
284 | 284 | |
285 | - if(defined('DEPLOYNAUT_CAPFILE')) { |
|
285 | + if (defined('DEPLOYNAUT_CAPFILE')) { |
|
286 | 286 | $capFile = DEPLOYNAUT_CAPFILE; |
287 | 287 | } else { |
288 | - $capFile = ASSETS_PATH . '/Capfile'; |
|
288 | + $capFile = ASSETS_PATH.'/Capfile'; |
|
289 | 289 | } |
290 | 290 | file_put_contents($capFile, $cap); |
291 | 291 | |
292 | - $command = "{$envString}cap -f " . escapeshellarg($capFile) . " -vv $name $action ROLES=$roles"; |
|
293 | - foreach($args as $argName => $argVal) { |
|
294 | - $command .= ' -s ' . escapeshellarg($argName) . '=' . escapeshellarg($argVal); |
|
292 | + $command = "{$envString}cap -f ".escapeshellarg($capFile)." -vv $name $action ROLES=$roles"; |
|
293 | + foreach ($args as $argName => $argVal) { |
|
294 | + $command .= ' -s '.escapeshellarg($argName).'='.escapeshellarg($argVal); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | $log->write(sprintf('Running command: %s', $command)); |
@@ -325,16 +325,16 @@ discard block |
||
325 | 325 | $filepathBase = $dataArchive->generateFilepath($dataTransfer); |
326 | 326 | mkdir($filepathBase, 0700, true); |
327 | 327 | |
328 | - $databasePath = $filepathBase . DIRECTORY_SEPARATOR . 'database.sql'; |
|
328 | + $databasePath = $filepathBase.DIRECTORY_SEPARATOR.'database.sql'; |
|
329 | 329 | |
330 | 330 | // Backup database |
331 | - if(in_array($dataTransfer->Mode, array('all', 'db'))) { |
|
331 | + if (in_array($dataTransfer->Mode, array('all', 'db'))) { |
|
332 | 332 | $log->write(sprintf('Backup of database from "%s" started', $name)); |
333 | 333 | $command = $this->getCommand('data:getdb', 'db', $environment, array('data_path' => $databasePath), $log); |
334 | 334 | $command->run(function($type, $buffer) use($log) { |
335 | 335 | $log->write($buffer); |
336 | 336 | }); |
337 | - if(!$command->isSuccessful()) { |
|
337 | + if (!$command->isSuccessful()) { |
|
338 | 338 | $this->extend('dataTransferFailure', $environment, $log); |
339 | 339 | throw new RuntimeException($command->getErrorOutput()); |
340 | 340 | } |
@@ -342,13 +342,13 @@ discard block |
||
342 | 342 | } |
343 | 343 | |
344 | 344 | // Backup assets |
345 | - if(in_array($dataTransfer->Mode, array('all', 'assets'))) { |
|
345 | + if (in_array($dataTransfer->Mode, array('all', 'assets'))) { |
|
346 | 346 | $log->write(sprintf('Backup of assets from "%s" started', $name)); |
347 | 347 | $command = $this->getCommand('data:getassets', 'web', $environment, array('data_path' => $filepathBase), $log); |
348 | 348 | $command->run(function($type, $buffer) use($log) { |
349 | 349 | $log->write($buffer); |
350 | 350 | }); |
351 | - if(!$command->isSuccessful()) { |
|
351 | + if (!$command->isSuccessful()) { |
|
352 | 352 | $this->extend('dataTransferFailure', $environment, $log); |
353 | 353 | throw new RuntimeException($command->getErrorOutput()); |
354 | 354 | } |
@@ -363,12 +363,12 @@ discard block |
||
363 | 363 | $log->write('Creating sspak...'); |
364 | 364 | |
365 | 365 | $sspakFilename = sprintf('%s.sspak', $dataArchive->generateFilename($dataTransfer)); |
366 | - $sspakFilepath = $filepathBase . DIRECTORY_SEPARATOR . $sspakFilename; |
|
366 | + $sspakFilepath = $filepathBase.DIRECTORY_SEPARATOR.$sspakFilename; |
|
367 | 367 | |
368 | 368 | try { |
369 | 369 | $dataArchive->attachFile($sspakFilepath, $dataTransfer); |
370 | 370 | $dataArchive->setArchiveFromFiles($filepathBase); |
371 | - } catch(Exception $e) { |
|
371 | + } catch (Exception $e) { |
|
372 | 372 | $log->write($e->getMessage()); |
373 | 373 | throw new RuntimeException($e->getMessage()); |
374 | 374 | } |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | $process = new AbortableProcess(sprintf('rm -rf %s/assets && rm -f %s', escapeshellarg($filepathBase), escapeshellarg($databasePath))); |
380 | 380 | $process->setTimeout(120); |
381 | 381 | $process->run(); |
382 | - if(!$process->isSuccessful()) { |
|
382 | + if (!$process->isSuccessful()) { |
|
383 | 383 | $log->write('Could not delete temporary files'); |
384 | 384 | throw new RuntimeException($process->getErrorOutput()); |
385 | 385 | } |
@@ -398,7 +398,7 @@ discard block |
||
398 | 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 | $log->write(sprintf('Rebuild of "%s" failed: %s', $name, $command->getErrorOutput())); |
403 | 403 | throw new RuntimeException($command->getErrorOutput()); |
404 | 404 | } |
@@ -428,14 +428,14 @@ discard block |
||
428 | 428 | }; |
429 | 429 | |
430 | 430 | // Restore database into target environment |
431 | - if(in_array($dataTransfer->Mode, array('all', 'db'))) { |
|
431 | + if (in_array($dataTransfer->Mode, array('all', 'db'))) { |
|
432 | 432 | $log->write(sprintf('Restore of database to "%s" started', $name)); |
433 | - $args = array('data_path' => $workingDir . DIRECTORY_SEPARATOR . 'database.sql'); |
|
433 | + $args = array('data_path' => $workingDir.DIRECTORY_SEPARATOR.'database.sql'); |
|
434 | 434 | $command = $this->getCommand('data:pushdb', 'db', $environment, $args, $log); |
435 | 435 | $command->run(function($type, $buffer) use($log) { |
436 | 436 | $log->write($buffer); |
437 | 437 | }); |
438 | - if(!$command->isSuccessful()) { |
|
438 | + if (!$command->isSuccessful()) { |
|
439 | 439 | $cleanupFn(); |
440 | 440 | $log->write(sprintf('Restore of database to "%s" failed: %s', $name, $command->getErrorOutput())); |
441 | 441 | $this->extend('dataTransferFailure', $environment, $log); |
@@ -445,14 +445,14 @@ discard block |
||
445 | 445 | } |
446 | 446 | |
447 | 447 | // Restore assets into target environment |
448 | - if(in_array($dataTransfer->Mode, array('all', 'assets'))) { |
|
448 | + if (in_array($dataTransfer->Mode, array('all', 'assets'))) { |
|
449 | 449 | $log->write(sprintf('Restore of assets to "%s" started', $name)); |
450 | - $args = array('data_path' => $workingDir . DIRECTORY_SEPARATOR . 'assets'); |
|
450 | + $args = array('data_path' => $workingDir.DIRECTORY_SEPARATOR.'assets'); |
|
451 | 451 | $command = $this->getCommand('data:pushassets', 'web', $environment, $args, $log); |
452 | 452 | $command->run(function($type, $buffer) use($log) { |
453 | 453 | $log->write($buffer); |
454 | 454 | }); |
455 | - if(!$command->isSuccessful()) { |
|
455 | + if (!$command->isSuccessful()) { |
|
456 | 456 | $cleanupFn(); |
457 | 457 | $log->write(sprintf('Restore of assets to "%s" failed: %s', $name, $command->getErrorOutput())); |
458 | 458 | $this->extend('dataTransferFailure', $environment, $log); |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | $timeout = 600; |
478 | 478 | $tick = 60; |
479 | 479 | |
480 | - if(!$url) { |
|
480 | + if (!$url) { |
|
481 | 481 | $log->write('Skipping site accessible check: no URL found.'); |
482 | 482 | return true; |
483 | 483 | } |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | // query the site every second. Note that if the URL doesn't respond, |
509 | 509 | // curl_exec will take 5 seconds to timeout (see CURLOPT_CONNECTTIMEOUT and CURLOPT_TIMEOUT above) |
510 | 510 | do { |
511 | - if(time() > $start + $timeout) { |
|
511 | + if (time() > $start + $timeout) { |
|
512 | 512 | $log->write(sprintf(' * Failed: check for %s timed out after %smin', $url, $timeout / 60)); |
513 | 513 | return false; |
514 | 514 | } |
@@ -517,13 +517,13 @@ discard block |
||
517 | 517 | |
518 | 518 | // check the HTTP response code for HTTP protocols |
519 | 519 | $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
520 | - if($status && !in_array($status, [500, 501, 502, 503, 504])) { |
|
520 | + if ($status && !in_array($status, [500, 501, 502, 503, 504])) { |
|
521 | 521 | $success = true; |
522 | 522 | } |
523 | 523 | |
524 | 524 | // check for any curl errors, mostly for checking the response state of non-HTTP protocols, |
525 | 525 | // but applies to checks of any protocol |
526 | - if($response && !curl_errno($ch)) { |
|
526 | + if ($response && !curl_errno($ch)) { |
|
527 | 527 | $success = true; |
528 | 528 | } |
529 | 529 | |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | } |
552 | 552 | |
553 | 553 | sleep(1); |
554 | - } while(!$success); |
|
554 | + } while (!$success); |
|
555 | 555 | |
556 | 556 | curl_close($ch); |
557 | 557 | $log->write(' * Success: site is accessible!'); |
@@ -50,14 +50,14 @@ |
||
50 | 50 | */ |
51 | 51 | public function getPackageFilename($identifier, $sha, $repositoryDir, DeploynautLogFile $log) { |
52 | 52 | // Fetch through the cache |
53 | - if($this->cache) { |
|
54 | - $identifier .= '-' . get_class($this) . '-' . $this->getIdentifier(); |
|
53 | + if ($this->cache) { |
|
54 | + $identifier .= '-'.get_class($this).'-'.$this->getIdentifier(); |
|
55 | 55 | return $this->cache->getPackageFilename($this, $identifier, $sha, $repositoryDir, $log); |
56 | 56 | |
57 | 57 | // Default, cacheless implementation |
58 | 58 | } else { |
59 | - $filename = TEMP_FOLDER . '/' . $sha . '.tar.gz'; |
|
60 | - if($this->generatePackage($sha, $repositoryDir, $filename, $log)) { |
|
59 | + $filename = TEMP_FOLDER.'/'.$sha.'.tar.gz'; |
|
60 | + if ($this->generatePackage($sha, $repositoryDir, $filename, $log)) { |
|
61 | 61 | return $filename; |
62 | 62 | } |
63 | 63 | } |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | * Generate the package |
31 | 31 | */ |
32 | 32 | public function generatePackage($sha, $baseDir, $outputFilename, DeploynautLogFile $log) { |
33 | - $tempPath = TEMP_FOLDER . "/" . str_replace(".tar.gz", "", basename($outputFilename)); |
|
34 | - if(!file_exists($tempPath)) { |
|
33 | + $tempPath = TEMP_FOLDER."/".str_replace(".tar.gz", "", basename($outputFilename)); |
|
34 | + if (!file_exists($tempPath)) { |
|
35 | 35 | mkdir($tempPath); |
36 | 36 | } |
37 | 37 | |
@@ -42,22 +42,22 @@ discard block |
||
42 | 42 | // Execute these in sequence until there's a failure |
43 | 43 | $processes = array( |
44 | 44 | // Export the relevant SHA into a temp folder |
45 | - new AbortableProcess("git archive $sha | tar -x -C " . $escapedTempPath, $baseDir), |
|
45 | + new AbortableProcess("git archive $sha | tar -x -C ".$escapedTempPath, $baseDir), |
|
46 | 46 | // Run build script |
47 | 47 | new AbortableProcess($this->buildScript, $tempPath, null, null, 3600), |
48 | 48 | // Compress the result |
49 | - new AbortableProcess("tar -czf " . $escapedOutputFile . " " . $escapedTempDir, dirname($tempPath)), |
|
49 | + new AbortableProcess("tar -czf ".$escapedOutputFile." ".$escapedTempDir, dirname($tempPath)), |
|
50 | 50 | ); |
51 | 51 | |
52 | 52 | // Call at the end, regardless of success or failure |
53 | 53 | $cleanup = array( |
54 | 54 | // Delete the temporary staging folder |
55 | - new AbortableProcess("rm -rf " . $escapedTempPath), |
|
55 | + new AbortableProcess("rm -rf ".$escapedTempPath), |
|
56 | 56 | ); |
57 | 57 | |
58 | 58 | try { |
59 | 59 | $this->executeProcesses($processes, $log); |
60 | - } catch(Exception $e) { |
|
60 | + } catch (Exception $e) { |
|
61 | 61 | // Execute cleanup on failure |
62 | 62 | $this->executeProcesses($cleanup, $log); |
63 | 63 | throw $e; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @param DeploynautLogFile $log The log to send output to |
76 | 76 | */ |
77 | 77 | protected function executeProcesses($processes, DeploynautLogFile $log) { |
78 | - foreach($processes as $process) { |
|
78 | + foreach ($processes as $process) { |
|
79 | 79 | $process->mustRun(function($type, $buffer) use($log) { |
80 | 80 | $log->write($buffer); |
81 | 81 | }); |
@@ -48,25 +48,25 @@ discard block |
||
48 | 48 | $repositoryDir, |
49 | 49 | DeploynautLogFile $log |
50 | 50 | ) { |
51 | - if(!$this->baseDir) { |
|
51 | + if (!$this->baseDir) { |
|
52 | 52 | throw new \LogicException("Can't use PackageCache without setting BaseDir"); |
53 | 53 | } |
54 | 54 | |
55 | - $buildPath = $this->baseDir . '/' . $this->sanitiseDirName($identifier); |
|
55 | + $buildPath = $this->baseDir.'/'.$this->sanitiseDirName($identifier); |
|
56 | 56 | $filename = "$buildPath/$sha.tar.gz"; |
57 | 57 | |
58 | - if(!file_exists($this->baseDir)) { |
|
59 | - if(!mkdir($this->baseDir)) { |
|
58 | + if (!file_exists($this->baseDir)) { |
|
59 | + if (!mkdir($this->baseDir)) { |
|
60 | 60 | throw new \LogicException("Can't create base dir {$this->baseDir}"); |
61 | 61 | } |
62 | 62 | } |
63 | - if(!file_exists($buildPath)) { |
|
64 | - if(!mkdir($buildPath)) { |
|
63 | + if (!file_exists($buildPath)) { |
|
64 | + if (!mkdir($buildPath)) { |
|
65 | 65 | throw new \LogicException("Can't create build path $buildPath"); |
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | - if(file_exists($filename)) { |
|
69 | + if (file_exists($filename)) { |
|
70 | 70 | $log->write("Using previously generated package $filename"); |
71 | 71 | // This will ensure that our cache garbage collection will remove least-recently-accessed, |
72 | 72 | // rather than oldest. |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | return $filename; |
75 | 75 | |
76 | 76 | } else { |
77 | - if($this->cacheSize) { |
|
77 | + if ($this->cacheSize) { |
|
78 | 78 | $this->reduceDirSizeTo($buildPath, $this->cacheSize - 1, $log); |
79 | 79 | } |
80 | 80 | |
81 | - if($generator->generatePackage($sha, $repositoryDir, $filename, $log)) { |
|
81 | + if ($generator->generatePackage($sha, $repositoryDir, $filename, $log)) { |
|
82 | 82 | return $filename; |
83 | 83 | } |
84 | 84 | } |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | * @param DeploynautLogFile $log The log to send removal status messages to |
104 | 104 | */ |
105 | 105 | protected function reduceDirSizeTo($dir, $count, DeploynautLogFile $log) { |
106 | - $files = glob($dir . '/*.tar.gz'); |
|
107 | - if(sizeof($files) > $count) { |
|
106 | + $files = glob($dir.'/*.tar.gz'); |
|
107 | + if (sizeof($files) > $count) { |
|
108 | 108 | usort($files, function($a, $b) { |
109 | 109 | return filemtime($a) > filemtime($b); |
110 | 110 | }); |
111 | 111 | |
112 | - for($i = 0; $i < sizeof($files) - $count; $i++) { |
|
113 | - $log->write("Removing " . $files[$i] . " from package cache"); |
|
112 | + for ($i = 0; $i < sizeof($files) - $count; $i++) { |
|
113 | + $log->write("Removing ".$files[$i]." from package cache"); |
|
114 | 114 | unlink($files[$i]); |
115 | 115 | } |
116 | 116 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | $file = sprintf('%s/%s.deploy-history.txt', DEPLOYNAUT_LOG_PATH, $environment->getFullName()); |
43 | 43 | $CLI_file = escapeshellarg($file); |
44 | - $CLI_line = escapeshellarg(date('Y-m-d H:i:s') . " => $sha"); |
|
44 | + $CLI_line = escapeshellarg(date('Y-m-d H:i:s')." => $sha"); |
|
45 | 45 | |
46 | 46 | // Put maintenance page up |
47 | 47 | $this->enableMaintenance($environment, $log, $project); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $log->write("Well, that was a waste of time"); |
55 | 55 | |
56 | 56 | // Once the deployment has run it's necessary to update the maintenance page status |
57 | - if(!empty($options['leaveMaintenancePage'])) { |
|
57 | + if (!empty($options['leaveMaintenancePage'])) { |
|
58 | 58 | $this->enableMaintenance($environment, $log, $project); |
59 | 59 | } else { |
60 | 60 | // Remove maintenance page if we want it to |
@@ -70,7 +70,7 @@ |
||
70 | 70 | * @return string |
71 | 71 | */ |
72 | 72 | public function get($keyname) { |
73 | - if(array_key_exists($keyname, $this->data)) { |
|
73 | + if (array_key_exists($keyname, $this->data)) { |
|
74 | 74 | return $this->data[$keyname]; |
75 | 75 | } |
76 | 76 | return ''; |