mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 06:42:41 +01:00
Add a --conduit-token parameter to arc
Summary: Ref T5955. This makes it easier to write scripts which call Conduit via `arc call-conduit`. Test Plan: Used `arc --conduit-token ... call-conduit user.whoami` to make calls as various users. Reviewers: btrahan Reviewed By: btrahan Subscribers: mbishopim3, epriestley Maniphest Tasks: T5955 Differential Revision: https://secure.phabricator.com/D12717
This commit is contained in:
parent
8919a9c5b5
commit
111b9b035a
3 changed files with 36 additions and 1 deletions
|
@ -30,6 +30,11 @@ $base_args->parsePartial(
|
||||||
'param' => 'uri',
|
'param' => 'uri',
|
||||||
'help' => pht('Connect to Phabricator install specified by __uri__.'),
|
'help' => pht('Connect to Phabricator install specified by __uri__.'),
|
||||||
),
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'conduit-token',
|
||||||
|
'param' => 'token',
|
||||||
|
'help' => pht('Use a specific authentication token.'),
|
||||||
|
),
|
||||||
array(
|
array(
|
||||||
'name' => 'conduit-version',
|
'name' => 'conduit-version',
|
||||||
'param' => 'version',
|
'param' => 'version',
|
||||||
|
@ -54,6 +59,7 @@ $base_args->parsePartial(
|
||||||
$config_trace_mode = $base_args->getArg('trace');
|
$config_trace_mode = $base_args->getArg('trace');
|
||||||
|
|
||||||
$force_conduit = $base_args->getArg('conduit-uri');
|
$force_conduit = $base_args->getArg('conduit-uri');
|
||||||
|
$force_token = $base_args->getArg('conduit-token');
|
||||||
$force_conduit_version = $base_args->getArg('conduit-version');
|
$force_conduit_version = $base_args->getArg('conduit-version');
|
||||||
$conduit_timeout = $base_args->getArg('conduit-timeout');
|
$conduit_timeout = $base_args->getArg('conduit-timeout');
|
||||||
$skip_arcconfig = $base_args->getArg('skip-arcconfig');
|
$skip_arcconfig = $base_args->getArg('skip-arcconfig');
|
||||||
|
@ -198,6 +204,9 @@ try {
|
||||||
if ($force_conduit_version) {
|
if ($force_conduit_version) {
|
||||||
$workflow->forceConduitVersion($force_conduit_version);
|
$workflow->forceConduitVersion($force_conduit_version);
|
||||||
}
|
}
|
||||||
|
if ($force_token) {
|
||||||
|
$workflow->forceConduitToken($force_token);
|
||||||
|
}
|
||||||
if ($conduit_timeout) {
|
if ($conduit_timeout) {
|
||||||
$workflow->setConduitTimeout($conduit_timeout);
|
$workflow->setConduitTimeout($conduit_timeout);
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,6 +189,9 @@ EOTEXT
|
||||||
Ignore configured Conduit URI and use an explicit one instead. Mostly
|
Ignore configured Conduit URI and use an explicit one instead. Mostly
|
||||||
useful for Arcanist development.
|
useful for Arcanist development.
|
||||||
|
|
||||||
|
__--conduit-token__ __token__
|
||||||
|
Ignore configured credentials and use an explicit API token instead.
|
||||||
|
|
||||||
__--conduit-version__ __version__
|
__--conduit-version__ __version__
|
||||||
Ignore software version and claim to be running some other version
|
Ignore software version and claim to be running some other version
|
||||||
instead. Mostly useful for Arcanist development. May cause bad things
|
instead. Mostly useful for Arcanist development. May cause bad things
|
||||||
|
|
|
@ -48,6 +48,7 @@ abstract class ArcanistWorkflow extends Phobject {
|
||||||
private $conduitCredentials;
|
private $conduitCredentials;
|
||||||
private $conduitAuthenticated;
|
private $conduitAuthenticated;
|
||||||
private $forcedConduitVersion;
|
private $forcedConduitVersion;
|
||||||
|
private $forcedConduitToken;
|
||||||
private $conduitTimeout;
|
private $conduitTimeout;
|
||||||
|
|
||||||
private $userPHID;
|
private $userPHID;
|
||||||
|
@ -251,6 +252,21 @@ abstract class ArcanistWorkflow extends Phobject {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Force use of a specific API token.
|
||||||
|
*
|
||||||
|
* Controlled by the --conduit-token flag.
|
||||||
|
*
|
||||||
|
* @param string API token to use.
|
||||||
|
* @return this
|
||||||
|
* @task conduit
|
||||||
|
*/
|
||||||
|
final public function forceConduitToken($token) {
|
||||||
|
$this->forcedConduitToken = $token;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the protocol version the client should identify with.
|
* Get the protocol version the client should identify with.
|
||||||
*
|
*
|
||||||
|
@ -325,10 +341,17 @@ abstract class ArcanistWorkflow extends Phobject {
|
||||||
// If we have `token`, this server supports the simpler, new-style
|
// If we have `token`, this server supports the simpler, new-style
|
||||||
// token-based authentication. Use that instead of all the certificate
|
// token-based authentication. Use that instead of all the certificate
|
||||||
// stuff.
|
// stuff.
|
||||||
|
$token = null;
|
||||||
if (isset($credentials['token'])) {
|
if (isset($credentials['token'])) {
|
||||||
|
$token = $credentials['token'];
|
||||||
|
}
|
||||||
|
if ($this->forcedConduitToken) {
|
||||||
|
$token = $this->forcedConduitToken;
|
||||||
|
}
|
||||||
|
if (strlen($token)) {
|
||||||
$conduit = $this->getConduit();
|
$conduit = $this->getConduit();
|
||||||
|
|
||||||
$conduit->setConduitToken($credentials['token']);
|
$conduit->setConduitToken($token);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$result = $this->getConduit()->callMethodSynchronous(
|
$result = $this->getConduit()->callMethodSynchronous(
|
||||||
|
|
Loading…
Reference in a new issue