@@ -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 | } |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | return true; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - return (bool) $this->Environments()->filterByCallback(function ($env) use ($member) { |
|
| 314 | + return (bool) $this->Environments()->filterByCallback(function($env) use ($member) { |
|
| 315 | 315 | return $env->canRestore($member); |
| 316 | 316 | })->Count(); |
| 317 | 317 | } |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | return true; |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - return (bool) $this->Environments()->filterByCallback(function ($env) use ($member) { |
|
| 335 | + return (bool) $this->Environments()->filterByCallback(function($env) use ($member) { |
|
| 336 | 336 | return $env->canBackup($member); |
| 337 | 337 | })->Count(); |
| 338 | 338 | } |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | return true; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - return (bool) $this->Environments()->filterByCallback(function ($env) use ($member) { |
|
| 356 | + return (bool) $this->Environments()->filterByCallback(function($env) use ($member) { |
|
| 357 | 357 | return $env->canUploadArchive($member); |
| 358 | 358 | })->Count(); |
| 359 | 359 | } |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | return true; |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | - return (bool) $this->Environments()->filterByCallback(function ($env) use ($member) { |
|
| 377 | + return (bool) $this->Environments()->filterByCallback(function($env) use ($member) { |
|
| 378 | 378 | return $env->canDownloadArchive($member); |
| 379 | 379 | })->Count(); |
| 380 | 380 | } |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | // Key-pair is available, use it. |
| 434 | 434 | $processEnv = [ |
| 435 | 435 | 'IDENT_KEY' => $this->getPrivateKeyPath(), |
| 436 | - 'GIT_SSH' => BASE_PATH . "/deploynaut/git-deploy.sh" |
|
| 436 | + 'GIT_SSH' => BASE_PATH."/deploynaut/git-deploy.sh" |
|
| 437 | 437 | ]; |
| 438 | 438 | } else { |
| 439 | 439 | $processEnv = []; |
@@ -521,7 +521,7 @@ discard block |
||
| 521 | 521 | |
| 522 | 522 | $currentMember = self::$_current_member_cache; |
| 523 | 523 | return $this->Environments() |
| 524 | - ->filterByCallBack(function ($item) use ($currentMember) { |
|
| 524 | + ->filterByCallBack(function($item) use ($currentMember) { |
|
| 525 | 525 | return $item->canView($currentMember); |
| 526 | 526 | }); |
| 527 | 527 | } |
@@ -540,14 +540,14 @@ discard block |
||
| 540 | 540 | * @return false|DNDeployment |
| 541 | 541 | */ |
| 542 | 542 | public function currentBuilds() { |
| 543 | - if (!isset(self::$relation_cache['currentBuilds.' . $this->ID])) { |
|
| 543 | + if (!isset(self::$relation_cache['currentBuilds.'.$this->ID])) { |
|
| 544 | 544 | $currentBuilds = []; |
| 545 | 545 | foreach ($this->Environments() as $env) { |
| 546 | 546 | $currentBuilds[$env->Name] = $env->CurrentBuild(); |
| 547 | 547 | } |
| 548 | - self::$relation_cache['currentBuilds.' . $this->ID] = $currentBuilds; |
|
| 548 | + self::$relation_cache['currentBuilds.'.$this->ID] = $currentBuilds; |
|
| 549 | 549 | } |
| 550 | - return self::$relation_cache['currentBuilds.' . $this->ID]; |
|
| 550 | + return self::$relation_cache['currentBuilds.'.$this->ID]; |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | /** |
@@ -788,7 +788,7 @@ discard block |
||
| 788 | 788 | */ |
| 789 | 789 | public function getPublicKeyPath() { |
| 790 | 790 | if ($privateKey = $this->getPrivateKeyPath()) { |
| 791 | - return $privateKey . '.pub'; |
|
| 791 | + return $privateKey.'.pub'; |
|
| 792 | 792 | } |
| 793 | 793 | return null; |
| 794 | 794 | } |
@@ -803,7 +803,7 @@ discard block |
||
| 803 | 803 | if (!empty($keyDir)) { |
| 804 | 804 | $filter = FileNameFilter::create(); |
| 805 | 805 | $name = $filter->filter($this->Name); |
| 806 | - return $keyDir . '/' . $name; |
|
| 806 | + return $keyDir.'/'.$name; |
|
| 807 | 807 | } |
| 808 | 808 | return null; |
| 809 | 809 | } |
@@ -822,7 +822,7 @@ discard block |
||
| 822 | 822 | $filter = FileNameFilter::create(); |
| 823 | 823 | $name = $filter->filter($this->Name); |
| 824 | 824 | |
| 825 | - return $this->DNData()->getKeyDir() . '/' . $name; |
|
| 825 | + return $this->DNData()->getKeyDir().'/'.$name; |
|
| 826 | 826 | } |
| 827 | 827 | |
| 828 | 828 | /** |
@@ -848,7 +848,7 @@ discard block |
||
| 848 | 848 | /* Look for each whitelisted hostname */ |
| 849 | 849 | foreach ($interfaces as $host => $interface) { |
| 850 | 850 | /* See if the CVS Path is for this hostname, followed by some junk (maybe a port), then the path */ |
| 851 | - if (preg_match('{^[^.]*' . $host . '(.*?)([/a-zA-Z].+)}', $this->CVSPath, $match)) { |
|
| 851 | + if (preg_match('{^[^.]*'.$host.'(.*?)([/a-zA-Z].+)}', $this->CVSPath, $match)) { |
|
| 852 | 852 | |
| 853 | 853 | $path = $match[2]; |
| 854 | 854 | |
@@ -859,10 +859,10 @@ discard block |
||
| 859 | 859 | $components = explode('.', $host); |
| 860 | 860 | |
| 861 | 861 | foreach ($regex as $pattern => $replacement) { |
| 862 | - $path = preg_replace('/' . $pattern . '/', $replacement, $path); |
|
| 862 | + $path = preg_replace('/'.$pattern.'/', $replacement, $path); |
|
| 863 | 863 | } |
| 864 | 864 | |
| 865 | - $uxurl = Controller::join_links($scheme . '://', $host, $path); |
|
| 865 | + $uxurl = Controller::join_links($scheme.'://', $host, $path); |
|
| 866 | 866 | |
| 867 | 867 | if (array_key_exists('commit', $interface) && $interface['commit'] == false) { |
| 868 | 868 | $commiturl = false; |
@@ -989,7 +989,7 @@ discard block |
||
| 989 | 989 | // {@see DataObject::extendedCan()} |
| 990 | 990 | $isDone = $this->extend('isProjectReady'); |
| 991 | 991 | if ($isDone && is_array($isDone)) { |
| 992 | - $isDone = array_filter($isDone, function ($val) { |
|
| 992 | + $isDone = array_filter($isDone, function($val) { |
|
| 993 | 993 | return !is_null($val); |
| 994 | 994 | }); |
| 995 | 995 | |
@@ -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); |