| @@ -31,7 +31,7 @@ | ||
| 31 | 31 | * Do the actual job by calling the appropiate backend | 
| 32 | 32 | */ | 
| 33 | 33 |  	public function perform() { | 
| 34 | - echo "[-] PingJob starting" . PHP_EOL; | |
| 34 | + echo "[-] PingJob starting".PHP_EOL; | |
| 35 | 35 | $log = new DeploynautLogFile($this->args['logfile']); | 
| 36 | 36 | |
| 37 | 37 | $ping = DNPing::get()->byID($this->args['pingID']); | 
| @@ -73,7 +73,7 @@ discard block | ||
| 73 | 73 | substr($sha, 0, 8), | 
| 74 | 74 | $branch->LastUpdated()->TimeDiff() | 
| 75 | 75 | ); | 
| 76 | - $branches[$sha . '-' . $name] = $branchValue; | |
| 76 | + $branches[$sha.'-'.$name] = $branchValue; | |
| 77 | 77 | } | 
| 78 | 78 | |
| 79 | 79 | // Tags | 
| @@ -86,7 +86,7 @@ discard block | ||
| 86 | 86 | substr($sha, 0, 8), | 
| 87 | 87 | $branch->LastUpdated()->TimeDiff() | 
| 88 | 88 | ); | 
| 89 | - $tags[$sha . '-' . $tag] = $tagValue; | |
| 89 | + $tags[$sha.'-'.$tag] = $tagValue; | |
| 90 | 90 | } | 
| 91 | 91 | $tags = array_reverse($tags); | 
| 92 | 92 | |
| @@ -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 | }); | 
| @@ -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()) { | 
| @@ -133,7 +133,7 @@ discard block | ||
| 133 | 133 |  	protected function getUpdateStatus($ID) { | 
| 134 | 134 | $ping = DNGitFetch::get()->byID($ID); | 
| 135 | 135 |  		if (!$ping) { | 
| 136 | -			return $this->getAPIResponse(['message' => 'GIT update (' . $ID . ') not found'], 404); | |
| 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, | 
| @@ -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 |