1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 22:10:55 +01:00

Give getAlmanacServiceURI() an "options" parameter to prepare for read-only devices

Summary:
Depends on D19355. Ref T10883. Ref T13120. Rather than adding a million parameters here, wrap the selector-parameters in an `$options`.

The next change adds a new "writable" option to support forcing selection of writable hosts.

Test Plan: Pulled and pushed via HTTP and SSH, viewed repositories via Diffusion.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13120, T10883

Differential Revision: https://secure.phabricator.com/D19356
This commit is contained in:
epriestley 2018-04-12 06:10:32 -07:00
parent 6f810d7813
commit 7c7e6d555b
3 changed files with 26 additions and 12 deletions

View file

@ -431,10 +431,12 @@ final class DiffusionServeController extends DiffusionController {
$uri = $repository->getAlmanacServiceURI(
$viewer,
$is_cluster_request,
array(
'http',
'https',
'neverProxy' => $is_cluster_request,
'protocols' => array(
'http',
'https',
),
));
if ($uri) {
$future = $this->getRequest()->newClusterProxyFuture($uri);

View file

@ -151,9 +151,11 @@ abstract class DiffusionSSHWorkflow extends PhabricatorSSHWorkflow {
$is_cluster_request = $this->getIsClusterRequest();
$uri = $repository->getAlmanacServiceURI(
$viewer,
$is_cluster_request,
array(
'ssh',
'neverProxy' => $is_cluster_request,
'protocols' => array(
'ssh',
),
));
if ($uri) {

View file

@ -1897,14 +1897,22 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
* services, returning raw URIs.
*
* @param PhabricatorUser Viewing user.
* @param bool `true` to throw if a remote URI would be returned.
* @param list<string> List of allowable protocols.
* @param map<string, wild> Constraints on selectable services.
* @return string|null URI, or `null` for local repositories.
*/
public function getAlmanacServiceURI(
PhabricatorUser $viewer,
$never_proxy,
array $protocols) {
array $options) {
PhutilTypeSpec::checkMap(
$options,
array(
'neverProxy' => 'bool',
'protocols' => 'list<string>',
));
$never_proxy = $options['neverProxy'];
$protocols = $options['protocols'];
$cache_key = $this->getAlmanacServiceCacheKey();
if (!$cache_key) {
@ -2077,10 +2085,12 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
$uri = $this->getAlmanacServiceURI(
$viewer,
$never_proxy,
array(
'http',
'https',
'neverProxy' => $never_proxy,
'protocols' => array(
'http',
'https',
),
));
if ($uri === null) {
return null;