@@ -60,7 +60,7 @@ |
||
60 | 60 | * @return mixed |
61 | 61 | */ |
62 | 62 | public function __get($property) { |
63 | - if(isset($this->record[$property])) { |
|
63 | + if (isset($this->record[$property])) { |
|
64 | 64 | return $this->record[$property]; |
65 | 65 | } |
66 | 66 | return null; |
@@ -49,20 +49,20 @@ discard block |
||
49 | 49 | protected function getJobs() { |
50 | 50 | $jobs = new ArrayList(); |
51 | 51 | |
52 | - $resqueJobs = Resque::redis()->lrange('queue:' . $this->Name, 0, -1); |
|
53 | - if(!$resqueJobs) { |
|
52 | + $resqueJobs = Resque::redis()->lrange('queue:'.$this->Name, 0, -1); |
|
53 | + if (!$resqueJobs) { |
|
54 | 54 | $jobs->push(new ResqueJob(array( |
55 | 55 | 'Name' => 'null', |
56 | 56 | 'Value' => 'null', |
57 | 57 | ))); |
58 | 58 | return $jobs; |
59 | 59 | } |
60 | - foreach($resqueJobs as $idx => $job) { |
|
60 | + foreach ($resqueJobs as $idx => $job) { |
|
61 | 61 | $stdClass = json_decode($job); |
62 | - if($stdClass->class === 'CapistranoDeploy' || $stdClass->class === 'DeployJob') { |
|
62 | + if ($stdClass->class === 'CapistranoDeploy' || $stdClass->class === 'DeployJob') { |
|
63 | 63 | $value = $stdClass->args[0]->projectName |
64 | - . ':' . $stdClass->args[0]->environment |
|
65 | - . ' - ' . $stdClass->args[0]->sha; |
|
64 | + . ':'.$stdClass->args[0]->environment |
|
65 | + . ' - '.$stdClass->args[0]->sha; |
|
66 | 66 | $jobs->push(new ResqueJob(array( |
67 | 67 | 'Name' => $stdClass->class, |
68 | 68 | 'Value' => $value, |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @return mixed |
112 | 112 | */ |
113 | 113 | public function __get($property) { |
114 | - if(isset($this->record[$property])) { |
|
114 | + if (isset($this->record[$property])) { |
|
115 | 115 | return $this->record[$property]; |
116 | 116 | } |
117 | 117 | return null; |
@@ -15,7 +15,7 @@ |
||
15 | 15 | class AbortableProcess extends \Symfony\Component\Process\Process { |
16 | 16 | public function run($callback = null) { |
17 | 17 | $this->start($callback); |
18 | - while($this->isRunning()) { |
|
18 | + while ($this->isRunning()) { |
|
19 | 19 | $this->checkTimeout(); |
20 | 20 | sleep(1); |
21 | 21 | } |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | public function alarmHandler() { |
19 | 19 | $sigFile = $this->args['sigFile']; |
20 | 20 | if (file_exists($sigFile) && is_readable($sigFile) && is_writable($sigFile)) { |
21 | - $signal = (int)file_get_contents($sigFile); |
|
22 | - if (is_int($signal) && in_array((int)$signal, [ |
|
21 | + $signal = (int) file_get_contents($sigFile); |
|
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 { |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | // to this job as a whole (including any subprocesses such as spawned by Symfony). |
61 | 61 | posix_setsid(); |
62 | 62 | |
63 | - if(function_exists('pcntl_alarm') && function_exists('pcntl_signal')) { |
|
63 | + if (function_exists('pcntl_alarm') && function_exists('pcntl_signal')) { |
|
64 | 64 | if (!empty($this->args['sigFile'])) { |
65 | - echo sprintf('[-] Signal file requested, polling "%s".' . PHP_EOL, $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']); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | // deploy onto a clean environment will not be performing any backup regardless of |
93 | 93 | // whether the predeploy_backup option was passed or not. |
94 | 94 | // Sometimes predeploy_backup comes through as string false from the frontend. |
95 | - if( |
|
95 | + if ( |
|
96 | 96 | !empty($this->args['predeploy_backup']) |
97 | 97 | && $this->args['predeploy_backup'] !== 'false' |
98 | 98 | && !empty($currentBuild) |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | // Disallow concurrent deployments (don't rely on queuing implementation to restrict this) |
115 | 115 | // Only consider deployments started in the last 30 minutes (older jobs probably got stuck) |
116 | 116 | $runningDeployments = $environment->runningDeployments()->exclude('ID', $this->args['deploymentID']); |
117 | - if($runningDeployments->count()) { |
|
117 | + if ($runningDeployments->count()) { |
|
118 | 118 | $runningDeployment = $runningDeployments->first(); |
119 | 119 | $message = sprintf( |
120 | 120 | 'Error: another deployment is in progress (started at %s by %s)', |
@@ -134,14 +134,14 @@ discard block |
||
134 | 134 | // all options from the DeploymentStrategy merged in, including sha. |
135 | 135 | $this->args |
136 | 136 | ); |
137 | - } catch(Exception $e) { |
|
137 | + } catch (Exception $e) { |
|
138 | 138 | // DeploynautJob will automatically trigger onFailure. |
139 | - echo "[-] DeployJob failed" . PHP_EOL; |
|
139 | + echo "[-] DeployJob failed".PHP_EOL; |
|
140 | 140 | throw $e; |
141 | 141 | } |
142 | 142 | |
143 | 143 | $this->updateStatus(DNDeployment::TR_COMPLETE); |
144 | - echo "[-] DeployJob finished" . PHP_EOL; |
|
144 | + echo "[-] DeployJob finished".PHP_EOL; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | public function onFailure(Exception $exception) { |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | DB::connect($databaseConfig); |
161 | 161 | $backupDataTransfer->Status = 'Finished'; |
162 | 162 | $backupDataTransfer->write(); |
163 | - } catch(Exception $e) { |
|
163 | + } catch (Exception $e) { |
|
164 | 164 | global $databaseConfig; |
165 | 165 | DB::connect($databaseConfig); |
166 | 166 | $backupDataTransfer->Status = 'Failed'; |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @return string |
46 | 46 | */ |
47 | 47 | public function getRawFilePath() { |
48 | - return $this->basePath . '/' . $this->logFile; |
|
48 | + return $this->basePath.'/'.$this->logFile; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @return string |
54 | 54 | */ |
55 | 55 | public function getSanitisedLogFilePath() { |
56 | - return $this->basePath . '/' . strtolower(FileNameFilter::create()->filter($this->logFile)); |
|
56 | + return $this->basePath.'/'.strtolower(FileNameFilter::create()->filter($this->logFile)); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | // Make sure we write into the old path for existing logs. New logs use the sanitised file path instead. |
84 | 84 | $path = file_exists($this->getRawFilePath()) ? $this->getRawFilePath() : $this->getSanitisedLogFilePath(); |
85 | 85 | |
86 | - error_log('[' . date('Y-m-d H:i:s') . '] ' . $message . PHP_EOL, 3, $path); |
|
86 | + error_log('['.date('Y-m-d H:i:s').'] '.$message.PHP_EOL, 3, $path); |
|
87 | 87 | @chmod($path, 0666); |
88 | 88 | } |
89 | 89 |
@@ -9,19 +9,19 @@ discard block |
||
9 | 9 | $remove = true; |
10 | 10 | $dryRun = true; |
11 | 11 | |
12 | - if($request && $request->requestVar('remove') !== null) { |
|
13 | - $remove = (bool)$request->requestVar('remove'); |
|
12 | + if ($request && $request->requestVar('remove') !== null) { |
|
13 | + $remove = (bool) $request->requestVar('remove'); |
|
14 | 14 | } |
15 | 15 | |
16 | - if($request && $request->requestVar('dryrun') !== null) { |
|
17 | - $dryRun = (bool)$request->requestVar('dryrun'); |
|
16 | + if ($request && $request->requestVar('dryrun') !== null) { |
|
17 | + $dryRun = (bool) $request->requestVar('dryrun'); |
|
18 | 18 | } |
19 | 19 | |
20 | - if($dryRun) { |
|
20 | + if ($dryRun) { |
|
21 | 21 | echo "Running in dry run mode, no changes commited, "; |
22 | - echo "the output shows a prediction on what will happen." . PHP_EOL; |
|
23 | - echo "To skip dryrun, run the task like this:" . PHP_EOL; |
|
24 | - echo "./framework/sake dev/tasks/SyncProjectsAndEnvironments dryrun=0" . PHP_EOL . PHP_EOL; |
|
22 | + echo "the output shows a prediction on what will happen.".PHP_EOL; |
|
23 | + echo "To skip dryrun, run the task like this:".PHP_EOL; |
|
24 | + echo "./framework/sake dev/tasks/SyncProjectsAndEnvironments dryrun=0".PHP_EOL.PHP_EOL; |
|
25 | 25 | sleep(3); |
26 | 26 | } |
27 | 27 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | // Sync projects |
32 | 32 | $projects = DNProject::get(); |
33 | - if($remove) { |
|
33 | + if ($remove) { |
|
34 | 34 | $this->echoHeader('Removing obsolete projects'); |
35 | 35 | $this->removeObsoleteProjects($projectPaths, $dryRun); |
36 | 36 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $this->syncProjectPaths($projectPaths, $dryRun); |
39 | 39 | |
40 | 40 | $this->echoHeader('Syncing environment files'); |
41 | - foreach($projects as $project) { |
|
41 | + foreach ($projects as $project) { |
|
42 | 42 | $this->echoHeader($project->Name); |
43 | 43 | // Sync environments for each project |
44 | 44 | $environmentPaths = $data->getEnvironmentPaths($project->Name); |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | }, $paths); |
63 | 63 | |
64 | 64 | $removeList = $list->filter('Filename:not', $basePaths); |
65 | - if($removeList->count() === 0) { |
|
65 | + if ($removeList->count() === 0) { |
|
66 | 66 | return; |
67 | 67 | } |
68 | 68 | |
69 | - foreach($removeList as $remove) { |
|
70 | - $this->message('Removing "' . basename($remove->Name) . '" from db'); |
|
71 | - if(!$dryRun) { |
|
69 | + foreach ($removeList as $remove) { |
|
70 | + $this->message('Removing "'.basename($remove->Name).'" from db'); |
|
71 | + if (!$dryRun) { |
|
72 | 72 | $removeList->remove($remove); |
73 | 73 | } |
74 | 74 | } |
@@ -83,13 +83,13 @@ discard block |
||
83 | 83 | */ |
84 | 84 | protected function removeObsoleteProjects($paths, $dryrun = false) { |
85 | 85 | $removeList = DNProject::get()->filter('Name:not', $paths); |
86 | - if($removeList->count() == 0) { |
|
86 | + if ($removeList->count() == 0) { |
|
87 | 87 | return; |
88 | 88 | } |
89 | 89 | |
90 | - foreach($removeList as $remove) { |
|
91 | - $this->message($remove->Name . ' ' . $remove->Path); |
|
92 | - if(!$dryrun) { |
|
90 | + foreach ($removeList as $remove) { |
|
91 | + $this->message($remove->Name.' '.$remove->Path); |
|
92 | + if (!$dryrun) { |
|
93 | 93 | $removeList->remove($remove); |
94 | 94 | } |
95 | 95 | } |
@@ -106,22 +106,22 @@ discard block |
||
106 | 106 | $list = $project->Environments(); |
107 | 107 | |
108 | 108 | // Normalise paths in DB |
109 | - foreach($list as $item) { |
|
109 | + foreach ($list as $item) { |
|
110 | 110 | $real = realpath($item->Filename); |
111 | - if($real && $real != $item->Filename) { |
|
111 | + if ($real && $real != $item->Filename) { |
|
112 | 112 | $item->Filename = $real; |
113 | 113 | $item->write(); |
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | - foreach($paths as $path) { |
|
117 | + foreach ($paths as $path) { |
|
118 | 118 | $path = basename($path); |
119 | - if($list->filter('Filename', $path)->count()) { |
|
119 | + if ($list->filter('Filename', $path)->count()) { |
|
120 | 120 | continue; |
121 | 121 | } |
122 | 122 | |
123 | - $this->message('Adding "' . basename($path) . '" to db'); |
|
124 | - if(!$dryRun) { |
|
123 | + $this->message('Adding "'.basename($path).'" to db'); |
|
124 | + if (!$dryRun) { |
|
125 | 125 | $environment = DNEnvironment::create_from_path($path); |
126 | 126 | $environment->ProjectID = $project->ID; |
127 | 127 | $environment->write(); |
@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | * @param boolean $dryRun |
137 | 137 | */ |
138 | 138 | public function syncProjectPaths($paths, $dryRun = false) { |
139 | - foreach($paths as $path) { |
|
140 | - if(!DNProject::get()->filter('Name', $path)->count()) { |
|
139 | + foreach ($paths as $path) { |
|
140 | + if (!DNProject::get()->filter('Name', $path)->count()) { |
|
141 | 141 | $this->message($path); |
142 | - if(!$dryRun) { |
|
142 | + if (!$dryRun) { |
|
143 | 143 | DNProject::create_from_path($path)->write(); |
144 | 144 | } |
145 | 145 | } |
@@ -150,20 +150,20 @@ discard block |
||
150 | 150 | * @param string $text |
151 | 151 | */ |
152 | 152 | protected function message($text) { |
153 | - if(PHP_SAPI !== 'cli') { |
|
154 | - $text = '<p>' . $text . '</p>' . PHP_EOL; |
|
153 | + if (PHP_SAPI !== 'cli') { |
|
154 | + $text = '<p>'.$text.'</p>'.PHP_EOL; |
|
155 | 155 | } |
156 | - echo ' - ' . $text . PHP_EOL; |
|
156 | + echo ' - '.$text.PHP_EOL; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
160 | 160 | * @param string $text |
161 | 161 | */ |
162 | 162 | protected function echoHeader($text) { |
163 | - if(PHP_SAPI !== 'cli') { |
|
164 | - echo '<h2>' . $text . '</h2>' . PHP_EOL; |
|
163 | + if (PHP_SAPI !== 'cli') { |
|
164 | + echo '<h2>'.$text.'</h2>'.PHP_EOL; |
|
165 | 165 | } else { |
166 | - echo '# ' . $text . PHP_EOL; |
|
166 | + echo '# '.$text.PHP_EOL; |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | } |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | ->buildPermissionField('ArchiveUploaderGroups', 'ArchiveUploaders', $groups, $members) |
775 | 775 | ->setTitle('Who can upload?') |
776 | 776 | ->setDescription( |
777 | - 'Users who can upload archives linked to this environment into Deploynaut.<br />' . |
|
777 | + 'Users who can upload archives linked to this environment into Deploynaut.<br />'. |
|
778 | 778 | 'Linking them to an environment allows limiting download permissions (see below).' |
779 | 779 | ), |
780 | 780 | |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | // Add actions |
822 | 822 | $action = new FormAction('check', 'Check Connection'); |
823 | 823 | $action->setUseButtonTag(true); |
824 | - $dataURL = Director::absoluteBaseURL() . 'naut/api/' . $this->Project()->Name . '/' . $this->Name . '/ping'; |
|
824 | + $dataURL = Director::absoluteBaseURL().'naut/api/'.$this->Project()->Name.'/'.$this->Name.'/ping'; |
|
825 | 825 | $action->setAttribute('data-url', $dataURL); |
826 | 826 | $fields->insertBefore($action, 'Name'); |
827 | 827 | |
@@ -834,8 +834,8 @@ discard block |
||
834 | 834 | */ |
835 | 835 | public function onBeforeWrite() { |
836 | 836 | parent::onBeforeWrite(); |
837 | - if ($this->Name && $this->Name . '.rb' != $this->Filename) { |
|
838 | - $this->Filename = $this->Name . '.rb'; |
|
837 | + if ($this->Name && $this->Name.'.rb' != $this->Filename) { |
|
838 | + $this->Filename = $this->Name.'.rb'; |
|
839 | 839 | } |
840 | 840 | $this->checkEnvironmentPath(); |
841 | 841 | $this->writeConfigFile(); |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | if (!$this->Filename) { |
886 | 886 | return ''; |
887 | 887 | } |
888 | - return $this->DNData()->getEnvironmentDir() . '/' . $this->Project()->Name . '/' . $this->Filename; |
|
888 | + return $this->DNData()->getEnvironmentDir().'/'.$this->Project()->Name.'/'.$this->Filename; |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | /** |
@@ -1039,7 +1039,7 @@ discard block |
||
1039 | 1039 | && $this->Filename |
1040 | 1040 | && $this->CreateEnvConfig |
1041 | 1041 | ) { |
1042 | - $templateFile = $this->config()->template_file ?: BASE_PATH . '/deploynaut/environment.template'; |
|
1042 | + $templateFile = $this->config()->template_file ?: BASE_PATH.'/deploynaut/environment.template'; |
|
1043 | 1043 | file_put_contents($this->getConfigFilename(), file_get_contents($templateFile)); |
1044 | 1044 | } else if ($this->envFileExists() && $this->DeployConfig) { |
1045 | 1045 | file_put_contents($this->getConfigFilename(), $this->DeployConfig); |
@@ -50,19 +50,19 @@ discard block |
||
50 | 50 | * @return string |
51 | 51 | */ |
52 | 52 | public function Name() { |
53 | - return (string)htmlentities($this->branch->getName()); |
|
53 | + return (string) htmlentities($this->branch->getName()); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | public function Link() { |
57 | 57 | // Use a get-var for branch so that it can handle unsafe chars better |
58 | - return Controller::join_links($this->project->Link(), 'branch?name=' . urlencode($this->Name())); |
|
58 | + return Controller::join_links($this->project->Link(), 'branch?name='.urlencode($this->Name())); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @return string |
63 | 63 | */ |
64 | 64 | public function SHA() { |
65 | - return (string)htmlentities($this->branch->getCommit()->getHash()); |
|
65 | + return (string) htmlentities($this->branch->getCommit()->getHash()); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function LastUpdated() { |
80 | 80 | |
81 | - if($this->_lastUpdatedCache) { |
|
81 | + if ($this->_lastUpdatedCache) { |
|
82 | 82 | return $this->_lastUpdatedCache; |
83 | 83 | } |
84 | 84 | try { |
85 | 85 | $created = $this->branch->getCommit()->getCommitterDate(); |
86 | - } catch(Exception $e) { |
|
86 | + } catch (Exception $e) { |
|
87 | 87 | //occasionally parsing will fail this is a fallback to make it still work |
88 | 88 | return new SS_Datetime(); |
89 | 89 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @return string |
104 | 104 | */ |
105 | 105 | public function IsOpenByDefault() { |
106 | - if($this->Name() == 'master') { |
|
106 | + if ($this->Name() == 'master') { |
|
107 | 107 | return " open"; |
108 | 108 | } else { |
109 | 109 | return ""; |
@@ -19,27 +19,27 @@ |
||
19 | 19 | * |
20 | 20 | */ |
21 | 21 | public function perform() { |
22 | - echo "[-] CreateEnvJob starting" . PHP_EOL; |
|
22 | + echo "[-] CreateEnvJob starting".PHP_EOL; |
|
23 | 23 | |
24 | 24 | $log = new DeploynautLogFile($this->args['logfile']); |
25 | 25 | $envCreate = DNCreateEnvironment::get()->byId($this->args['createID']); |
26 | 26 | |
27 | 27 | // This is a bit icky, but there is no easy way of capturing a failed deploy by using the PHP Resque |
28 | 28 | try { |
29 | - if(!($envCreate && $envCreate->exists())) { |
|
29 | + if (!($envCreate && $envCreate->exists())) { |
|
30 | 30 | throw new RuntimeException(sprintf('Could not find create environment record %s', $args['createID'])); |
31 | 31 | } |
32 | 32 | |
33 | 33 | // This will throw and exception if it fails. |
34 | 34 | $envCreate->createEnvironment(); |
35 | 35 | |
36 | - } catch(Exception $e) { |
|
36 | + } catch (Exception $e) { |
|
37 | 37 | $log->write($e->getMessage()); |
38 | - echo "[-] CreateEnvJob failed" . PHP_EOL; |
|
38 | + echo "[-] CreateEnvJob failed".PHP_EOL; |
|
39 | 39 | throw $e; |
40 | 40 | } |
41 | 41 | $this->updateStatus('Finished'); |
42 | - echo "[-] CreateEnvJob finished" . PHP_EOL; |
|
42 | + echo "[-] CreateEnvJob finished".PHP_EOL; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |