@@ -19,9 +19,9 @@ discard block |
||
19 | 19 | |
20 | 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 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | } |
68 | 68 | |
69 | 69 | foreach($removeList as $remove) { |
70 | - $this->message('Removing "' . basename($remove->Name) . '" from db'); |
|
70 | + $this->message('Removing "'.basename($remove->Name).'" from db'); |
|
71 | 71 | if(!$dryRun) { |
72 | 72 | $removeList->remove($remove); |
73 | 73 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | } |
89 | 89 | |
90 | 90 | foreach($removeList as $remove) { |
91 | - $this->message($remove->Name . ' ' . $remove->Path); |
|
91 | + $this->message($remove->Name.' '.$remove->Path); |
|
92 | 92 | if(!$dryrun) { |
93 | 93 | $removeList->remove($remove); |
94 | 94 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | continue; |
121 | 121 | } |
122 | 122 | |
123 | - $this->message('Adding "' . basename($path) . '" to db'); |
|
123 | + $this->message('Adding "'.basename($path).'" to db'); |
|
124 | 124 | if(!$dryRun) { |
125 | 125 | $environment = DNEnvironment::create_from_path($path); |
126 | 126 | $environment->ProjectID = $project->ID; |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | */ |
152 | 152 | protected function message($text) { |
153 | 153 | if(PHP_SAPI !== 'cli') { |
154 | - $text = '<p>' . $text . '</p>' . PHP_EOL; |
|
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 | /** |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | */ |
162 | 162 | protected function echoHeader($text) { |
163 | 163 | if(PHP_SAPI !== 'cli') { |
164 | - echo '<h2>' . $text . '</h2>' . PHP_EOL; |
|
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 | } |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | $ping->write(); |
113 | 113 | $ping->start(); |
114 | 114 | |
115 | - $location = Director::absoluteBaseURL() . $this->Link() . '/ping/' . $ping->ID; |
|
115 | + $location = Director::absoluteBaseURL().$this->Link().'/ping/'.$ping->ID; |
|
116 | 116 | $output = array( |
117 | - 'message' => 'Ping queued as job ' . $ping->ResqueToken, |
|
117 | + 'message' => 'Ping queued as job '.$ping->ResqueToken, |
|
118 | 118 | 'href' => $location, |
119 | 119 | ); |
120 | 120 | |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | )); |
165 | 165 | $deploy = $strategy->createDeployment(); |
166 | 166 | $deploy->start(); |
167 | - $location = Director::absoluteBaseURL() . $this->Link() . '/deploy/' . $deploy->ID; |
|
167 | + $location = Director::absoluteBaseURL().$this->Link().'/deploy/'.$deploy->ID; |
|
168 | 168 | $output = array( |
169 | - 'message' => 'Deploy queued as job ' . $deploy->ResqueToken, |
|
169 | + 'message' => 'Deploy queued as job '.$deploy->ResqueToken, |
|
170 | 170 | 'href' => $location, |
171 | 171 | ); |
172 | 172 | $response = $this->getAPIResponse($output); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | protected function project404Response() { |
107 | 107 | $projectName = Convert::raw2xml($this->getRequest()->latestParam('Project')); |
108 | - return new SS_HTTPResponse('Project "' . $projectName . '" not found.', 404); |
|
108 | + return new SS_HTTPResponse('Project "'.$projectName.'" not found.', 404); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | protected function environment404Response() { |
115 | 115 | $envName = Convert::raw2xml($this->getRequest()->latestParam('Environment')); |
116 | - return new SS_HTTPResponse('Environment "' . $envName . '" not found.', 404); |
|
116 | + return new SS_HTTPResponse('Environment "'.$envName.'" not found.', 404); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | } |
17 | 17 | |
18 | 18 | public function perform() { |
19 | - echo "[-] DeployJob starting" . PHP_EOL; |
|
19 | + echo "[-] DeployJob starting".PHP_EOL; |
|
20 | 20 | $log = new DeploynautLogFile($this->args['logfile']); |
21 | 21 | |
22 | 22 | $deployment = DNDeployment::get()->byID($this->args['deploymentID']); |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | $this->args |
51 | 51 | ); |
52 | 52 | } catch(Exception $e) { |
53 | - echo "[-] DeployJob failed" . PHP_EOL; |
|
53 | + echo "[-] DeployJob failed".PHP_EOL; |
|
54 | 54 | throw $e; |
55 | 55 | } |
56 | 56 | $this->updateStatus('Finished'); |
57 | - echo "[-] DeployJob finished" . PHP_EOL; |
|
57 | + echo "[-] DeployJob finished".PHP_EOL; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -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']); |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * |
20 | 20 | */ |
21 | 21 | public function perform() { |
22 | - echo "[-] CreateEnvJob starting" . PHP_EOL; |
|
22 | + echo "[-] CreateEnvJob starting".PHP_EOL; |
|
23 | 23 | // This is a bit icky, but there is no easy way of capturing a failed deploy by using the PHP Resque |
24 | 24 | try { |
25 | 25 | $envCreate = DNCreateEnvironment::get()->byId($this->args['createID']); |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | $envCreate->createEnvironment(); |
32 | 32 | |
33 | 33 | } catch(Exception $e) { |
34 | - echo "[-] CreateEnvJob failed" . PHP_EOL; |
|
34 | + echo "[-] CreateEnvJob failed".PHP_EOL; |
|
35 | 35 | throw $e; |
36 | 36 | } |
37 | 37 | $this->updateStatus('Finished'); |
38 | - echo "[-] CreateEnvJob finished" . PHP_EOL; |
|
38 | + echo "[-] CreateEnvJob finished".PHP_EOL; |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -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(); |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | } catch(RuntimeException $exc) { |
84 | 84 | $log->write($exc->getMessage()); |
85 | 85 | |
86 | - echo "[-] DataTransferJob failed" . PHP_EOL; |
|
86 | + echo "[-] DataTransferJob failed".PHP_EOL; |
|
87 | 87 | throw $exc; |
88 | 88 | } |
89 | 89 | |
90 | 90 | $this->updateStatus('Finished'); |
91 | - echo "[-] DataTransferJob finished" . PHP_EOL; |
|
91 | + echo "[-] DataTransferJob finished".PHP_EOL; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -23,7 +23,7 @@ |
||
23 | 23 | $path = $project->getLocalCVSPath(); |
24 | 24 | $env = $this->args['env']; |
25 | 25 | |
26 | - $log->write('Starting git fetch for project "' . $project->Name . '"'); |
|
26 | + $log->write('Starting git fetch for project "'.$project->Name.'"'); |
|
27 | 27 | |
28 | 28 | // if an alternate user has been configured for clone, run the command as that user |
29 | 29 | // @todo Gitonomy doesn't seem to have any way to prefix the command properly, if you |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * @return bool |
257 | 257 | */ |
258 | 258 | public function canRestore($member = null) { |
259 | - if ($this->allowedAny( |
|
259 | + if($this->allowedAny( |
|
260 | 260 | array( |
261 | 261 | DNRoot::ALLOW_PROD_SNAPSHOT, |
262 | 262 | DNRoot::ALLOW_NON_PROD_SNAPSHOT |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * @return bool |
277 | 277 | */ |
278 | 278 | public function canBackup($member = null) { |
279 | - if ($this->allowedAny( |
|
279 | + if($this->allowedAny( |
|
280 | 280 | array( |
281 | 281 | DNRoot::ALLOW_PROD_SNAPSHOT, |
282 | 282 | DNRoot::ALLOW_NON_PROD_SNAPSHOT |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | * @return bool |
297 | 297 | */ |
298 | 298 | public function canUploadArchive($member = null) { |
299 | - if ($this->allowedAny( |
|
299 | + if($this->allowedAny( |
|
300 | 300 | array( |
301 | 301 | DNRoot::ALLOW_PROD_SNAPSHOT, |
302 | 302 | DNRoot::ALLOW_NON_PROD_SNAPSHOT |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * @return bool |
317 | 317 | */ |
318 | 318 | public function canDownloadArchive($member = null) { |
319 | - if ($this->allowedAny( |
|
319 | + if($this->allowedAny( |
|
320 | 320 | array( |
321 | 321 | DNRoot::ALLOW_PROD_SNAPSHOT, |
322 | 322 | DNRoot::ALLOW_NON_PROD_SNAPSHOT |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | // Key-pair is available, use it. |
386 | 386 | $processEnv = array( |
387 | 387 | 'IDENT_KEY' => $this->getPrivateKeyPath(), |
388 | - 'GIT_SSH' => BASE_PATH . "/deploynaut/git-deploy.sh" |
|
388 | + 'GIT_SSH' => BASE_PATH."/deploynaut/git-deploy.sh" |
|
389 | 389 | ); |
390 | 390 | } else { |
391 | 391 | $processEnv = array(); |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | * @return bool |
647 | 647 | */ |
648 | 648 | public function repoExists() { |
649 | - return file_exists(DEPLOYNAUT_LOCAL_VCS_PATH . '/' . $this->Name.'/HEAD'); |
|
649 | + return file_exists(DEPLOYNAUT_LOCAL_VCS_PATH.'/'.$this->Name.'/HEAD'); |
|
650 | 650 | } |
651 | 651 | |
652 | 652 | /** |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | * @return string |
665 | 665 | */ |
666 | 666 | public function getLocalCVSPath() { |
667 | - return DEPLOYNAUT_LOCAL_VCS_PATH . '/' . $this->Name; |
|
667 | + return DEPLOYNAUT_LOCAL_VCS_PATH.'/'.$this->Name; |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | /** |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | */ |
741 | 741 | public function getPublicKeyPath() { |
742 | 742 | if($privateKey = $this->getPrivateKeyPath()) { |
743 | - return $privateKey . '.pub'; |
|
743 | + return $privateKey.'.pub'; |
|
744 | 744 | } |
745 | 745 | return null; |
746 | 746 | } |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | if(!empty($keyDir)) { |
756 | 756 | $filter = FileNameFilter::create(); |
757 | 757 | $name = $filter->filter($this->Name); |
758 | - return $keyDir . '/' . $name; |
|
758 | + return $keyDir.'/'.$name; |
|
759 | 759 | } |
760 | 760 | return null; |
761 | 761 | } |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | $filter = FileNameFilter::create(); |
775 | 775 | $name = $filter->filter($this->Name); |
776 | 776 | |
777 | - return $this->DNData()->getKeyDir() . '/' . $name; |
|
777 | + return $this->DNData()->getKeyDir().'/'.$name; |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | /** |
@@ -861,7 +861,7 @@ discard block |
||
861 | 861 | /* Look for each whitelisted hostname */ |
862 | 862 | foreach($interfaces as $host => $interface) { |
863 | 863 | /* See if the CVS Path is for this hostname, followed by some junk (maybe a port), then the path */ |
864 | - if(preg_match('{^[^.]*' . $host . '(.*?)([/a-zA-Z].+)}', $this->CVSPath, $match)) { |
|
864 | + if(preg_match('{^[^.]*'.$host.'(.*?)([/a-zA-Z].+)}', $this->CVSPath, $match)) { |
|
865 | 865 | |
866 | 866 | $path = $match[2]; |
867 | 867 | |
@@ -872,10 +872,10 @@ discard block |
||
872 | 872 | $components = explode('.', $host); |
873 | 873 | |
874 | 874 | foreach($regex as $pattern => $replacement) { |
875 | - $path = preg_replace('/' . $pattern . '/', $replacement, $path); |
|
875 | + $path = preg_replace('/'.$pattern.'/', $replacement, $path); |
|
876 | 876 | } |
877 | 877 | |
878 | - $uxurl = Controller::join_links($scheme . '://', $host, $path); |
|
878 | + $uxurl = Controller::join_links($scheme.'://', $host, $path); |
|
879 | 879 | |
880 | 880 | if(array_key_exists('commit', $interface) && $interface['commit'] == false) { |
881 | 881 | $commiturl = false; |
@@ -959,14 +959,14 @@ discard block |
||
959 | 959 | * @return bool |
960 | 960 | */ |
961 | 961 | public function allowedAny($codes, $member = null) { |
962 | - if (!$member) { |
|
962 | + if(!$member) { |
|
963 | 963 | $member = Member::currentUser(); |
964 | 964 | } |
965 | 965 | |
966 | 966 | if(Permission::checkMember($member, 'ADMIN')) return true; |
967 | 967 | |
968 | 968 | $hits = $this->whoIsAllowedAny($codes)->filter('Member.ID', $member->ID)->count(); |
969 | - return ($hits>0 ? true : false); |
|
969 | + return ($hits > 0 ? true : false); |
|
970 | 970 | } |
971 | 971 | |
972 | 972 | } |
@@ -445,7 +445,7 @@ |
||
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
448 | - * @return false|Gitonomy\Git\Repository |
|
448 | + * @return Gitonomy\Git\Repository |
|
449 | 449 | */ |
450 | 450 | public function getRepository() { |
451 | 451 | if(!$this->repoExists()) { |
@@ -923,7 +923,9 @@ discard block |
||
923 | 923 | * @return SS_List |
924 | 924 | */ |
925 | 925 | public function whoIsAllowedAny($codes) { |
926 | - if(!is_array($codes)) $codes = array($codes); |
|
926 | + if(!is_array($codes)) { |
|
927 | + $codes = array($codes); |
|
928 | + } |
|
927 | 929 | |
928 | 930 | $SQLa_codes = Convert::raw2sql($codes); |
929 | 931 | $SQL_codes = join("','", $SQLa_codes); |
@@ -985,7 +987,9 @@ discard block |
||
985 | 987 | $member = Member::currentUser(); |
986 | 988 | } |
987 | 989 | |
988 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
990 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
991 | + return true; |
|
992 | + } |
|
989 | 993 | |
990 | 994 | $hits = $this->whoIsAllowedAny($codes)->filter('Member.ID', $member->ID)->count(); |
991 | 995 | return ($hits>0 ? true : false); |
@@ -1012,7 +1016,9 @@ discard block |
||
1012 | 1016 | }); |
1013 | 1017 | |
1014 | 1018 | // If anything returns false then we're not ready. |
1015 | - if($isDone) return min($isDone); |
|
1019 | + if($isDone) { |
|
1020 | + return min($isDone); |
|
1021 | + } |
|
1016 | 1022 | } |
1017 | 1023 | |
1018 | 1024 | return true; |