From bee3bc0570a32542c92f598e2afc49fe559adc3e Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 15 May 2020 08:20:00 -0700 Subject: [PATCH] (stable) Allow construction of a ConduitEngine with a bare ConduitClient Summary: See PHI1735. "ConduitEngine" was once a future pool, but this has moved to "HardpointEngine". This class may no longer make much sense. In Phacility code, "bin/host upload" depends on using the Uploader, which needs a "ConduitEngine", not a "ConduitClient". This workflow may use asymmetric key signing, which "ConduitEngine" does not support. To unblock PHI1735, provide glue code between "Client" and "Engine". But a "more correct" change is probably removal of "Engine". Test Plan: - Ran `bin/host upload`, uploaded files (with additional changes to wrap the Client). - Created this revision. Differential Revision: https://secure.phabricator.com/D21260 --- src/conduit/ArcanistConduitEngine.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/conduit/ArcanistConduitEngine.php b/src/conduit/ArcanistConduitEngine.php index 7817f52c..c9171245 100644 --- a/src/conduit/ArcanistConduitEngine.php +++ b/src/conduit/ArcanistConduitEngine.php @@ -40,7 +40,7 @@ final class ArcanistConduitEngine } public function newCall($method, array $parameters) { - if ($this->conduitURI == null) { + if ($this->conduitURI == null && $this->client === null) { $this->raiseURIException(); } @@ -78,9 +78,11 @@ final class ArcanistConduitEngine if ($token) { $client->setConduitToken($this->getConduitToken()); } + + $this->client = $client; } - return $client; + return $this->client; } private function raiseURIException() { @@ -105,4 +107,12 @@ final class ArcanistConduitEngine throw new ArcanistUsageException($block->drawConsoleString()); } + public static function newConduitEngineFromConduitClient( + ConduitClient $client) { + + $engine = new self(); + $engine->client = $client; + + return $engine; + } }