1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-11 15:21:03 +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( $uri = $repository->getAlmanacServiceURI(
$viewer, $viewer,
$is_cluster_request,
array( array(
'http', 'neverProxy' => $is_cluster_request,
'https', 'protocols' => array(
'http',
'https',
),
)); ));
if ($uri) { if ($uri) {
$future = $this->getRequest()->newClusterProxyFuture($uri); $future = $this->getRequest()->newClusterProxyFuture($uri);

View file

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

View file

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