@@ -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']); |
@@ -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 | }); |
@@ -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 |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | // Normalise "empty" values into dashes so comparisons are done properly. |
111 | 111 | // This means there is no diference between an empty string and a null |
112 | 112 | // but "0" is considered to be non-empty. |
113 | - if(empty($from) && !strlen($from)) $from = '-'; |
|
114 | - if(empty($to) && !strlen($to)) $to = '-'; |
|
113 | + if (empty($from) && !strlen($from)) $from = '-'; |
|
114 | + if (empty($to) && !strlen($to)) $to = '-'; |
|
115 | 115 | |
116 | 116 | return $this->changes[$title] = array( |
117 | 117 | 'from' => $from, |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function getChange($key) { |
172 | 172 | $changes = $this->getChanges(); |
173 | - if(array_key_exists($key, $changes)) { |
|
173 | + if (array_key_exists($key, $changes)) { |
|
174 | 174 | return new ArrayData($changes[$key]); |
175 | 175 | } |
176 | 176 | return null; |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | * @return string|null |
190 | 190 | */ |
191 | 191 | public function getOption($option) { |
192 | - if(!empty($this->options[$option])) { |
|
192 | + if (!empty($this->options[$option])) { |
|
193 | 193 | return $this->options[$option]; |
194 | 194 | } |
195 | 195 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | DeploymentStrategy::WARNING_CODE => 1, |
231 | 231 | DeploymentStrategy::ERROR_CODE => 2 |
232 | 232 | ]; |
233 | - if($map[$current] < $map[$code]) { |
|
233 | + if ($map[$current] < $map[$code]) { |
|
234 | 234 | $this->setValidationCode($code); |
235 | 235 | } |
236 | 236 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | ); |
260 | 260 | |
261 | 261 | $output = array(); |
262 | - foreach($fields as $field) { |
|
262 | + foreach ($fields as $field) { |
|
263 | 263 | $output[$field] = $this->$field; |
264 | 264 | } |
265 | 265 | return $output; |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | 'messages' |
301 | 301 | ); |
302 | 302 | |
303 | - foreach($fields as $field) { |
|
304 | - if(!empty($data[$field])) { |
|
303 | + foreach ($fields as $field) { |
|
304 | + if (!empty($data[$field])) { |
|
305 | 305 | $this->$field = $data[$field]; |
306 | 306 | } |
307 | 307 | } |
@@ -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 ''; |