Changeset View
Changeset View
Standalone View
Standalone View
src/runtime/ArcanistRuntime.php
Show First 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | private function executeCore(array $argv) { | ||||
$toolset = $this->newToolset($argv); | $toolset = $this->newToolset($argv); | ||||
$args->parsePartial($toolset->getToolsetArguments()); | $args->parsePartial($toolset->getToolsetArguments()); | ||||
$workflows = $this->newWorkflows($toolset); | $workflows = $this->newWorkflows($toolset); | ||||
$this->workflows = $workflows; | $this->workflows = $workflows; | ||||
$conduit_engine = $this->newConduitEngine($config); | $conduit_engine = $this->newConduitEngine($config, $args); | ||||
$this->conduitEngine = $conduit_engine; | $this->conduitEngine = $conduit_engine; | ||||
$phutil_workflows = array(); | $phutil_workflows = array(); | ||||
foreach ($workflows as $key => $workflow) { | foreach ($workflows as $key => $workflow) { | ||||
$phutil_workflows[$key] = $workflow->newPhutilWorkflow(); | $phutil_workflows[$key] = $workflow->newPhutilWorkflow(); | ||||
$workflow | $workflow | ||||
->setRuntime($this) | ->setRuntime($this) | ||||
▲ Show 20 Lines • Show All 568 Lines • ▼ Show 20 Lines | final class ArcanistRuntime { | ||||
public function getWorkflowStack() { | public function getWorkflowStack() { | ||||
return $this->stack; | return $this->stack; | ||||
} | } | ||||
public function getCurrentWorkflow() { | public function getCurrentWorkflow() { | ||||
return last($this->stack); | return last($this->stack); | ||||
} | } | ||||
private function newConduitEngine(ArcanistConfigurationSourceList $config) { | private function newConduitEngine( | ||||
ArcanistConfigurationSourceList $config, | |||||
PhutilArgumentParser $args) { | |||||
try { | |||||
$force_uri = $args->getArg('conduit-uri'); | |||||
} catch (PhutilArgumentSpecificationException $ex) { | |||||
$force_uri = null; | |||||
} | |||||
try { | |||||
$force_token = $args->getArg('conduit-token'); | |||||
} catch (PhutilArgumentSpecificationException $ex) { | |||||
$force_token = null; | |||||
} | |||||
if ($force_uri !== null) { | |||||
$conduit_uri = $force_uri; | |||||
} else { | |||||
$conduit_uri = $config->getConfig('phabricator.uri'); | $conduit_uri = $config->getConfig('phabricator.uri'); | ||||
if ($conduit_uri === null) { | if ($conduit_uri === null) { | ||||
// For now, read this older config from raw storage. There is currently | // For now, read this older config from raw storage. There is currently | ||||
// no definition of this option in the "toolsets" config list, and it | // no definition of this option in the "toolsets" config list, and it | ||||
// would be nice to get rid of it. | // would be nice to get rid of it. | ||||
$default_list = $config->getStorageValueList('default'); | $default_list = $config->getStorageValueList('default'); | ||||
if ($default_list) { | if ($default_list) { | ||||
$conduit_uri = last($default_list)->getValue(); | $conduit_uri = last($default_list)->getValue(); | ||||
} | } | ||||
} | } | ||||
} | |||||
if ($conduit_uri) { | if ($conduit_uri) { | ||||
// Set the URI path to '/api/'. TODO: Originally, I contemplated letting | // Set the URI path to '/api/'. TODO: Originally, I contemplated letting | ||||
// you deploy Phabricator somewhere other than the domain root, but ended | // you deploy Phabricator somewhere other than the domain root, but ended | ||||
// up never pursuing that. We should get rid of all "/api/" silliness | // up never pursuing that. We should get rid of all "/api/" silliness | ||||
// in things users are expected to configure. This is already happening | // in things users are expected to configure. This is already happening | ||||
// to some degree, e.g. "arc install-certificate" does it for you. | // to some degree, e.g. "arc install-certificate" does it for you. | ||||
$conduit_uri = new PhutilURI($conduit_uri); | $conduit_uri = new PhutilURI($conduit_uri); | ||||
$conduit_uri->setPath('/api/'); | $conduit_uri->setPath('/api/'); | ||||
$conduit_uri = phutil_string_cast($conduit_uri); | $conduit_uri = phutil_string_cast($conduit_uri); | ||||
} | } | ||||
$engine = new ArcanistConduitEngine(); | $engine = new ArcanistConduitEngine(); | ||||
if ($conduit_uri !== null) { | if ($conduit_uri !== null) { | ||||
$engine->setConduitURI($conduit_uri); | $engine->setConduitURI($conduit_uri); | ||||
} | } | ||||
// TODO: This isn't using "getConfig()" because we aren't defining a | // TODO: This isn't using "getConfig()" because we aren't defining a | ||||
// real config entry for the moment. | // real config entry for the moment. | ||||
if ($force_token !== null) { | |||||
$conduit_token = $force_token; | |||||
} else { | |||||
$hosts = array(); | $hosts = array(); | ||||
$hosts_list = $config->getStorageValueList('hosts'); | $hosts_list = $config->getStorageValueList('hosts'); | ||||
foreach ($hosts_list as $hosts_config) { | foreach ($hosts_list as $hosts_config) { | ||||
$hosts += $hosts_config->getValue(); | $hosts += $hosts_config->getValue(); | ||||
} | } | ||||
$host_config = idx($hosts, $conduit_uri, array()); | $host_config = idx($hosts, $conduit_uri, array()); | ||||
$user_name = idx($host_config, 'user'); | |||||
$conduit_token = idx($host_config, 'token'); | $conduit_token = idx($host_config, 'token'); | ||||
} | |||||
if ($conduit_token !== null) { | if ($conduit_token !== null) { | ||||
$engine->setConduitToken($conduit_token); | $engine->setConduitToken($conduit_token); | ||||
} | } | ||||
return $engine; | return $engine; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 89 Lines • Show Last 20 Lines |