@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add support for "harbormaster.target.search"

Summary: Ref T13222. See PHI986. See PHI896. Harbormaster build targets don't currently have a modern "*.search" API, but there's no reason not to provide one (even if some of the use cases are a little bit questionable).

Test Plan: {F6032423}

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13222

Differential Revision: https://secure.phabricator.com/D19841

+179 -1
+5
src/__phutil_library_map__.php
··· 1353 1353 'HarbormasterBuildTarget' => 'applications/harbormaster/storage/build/HarbormasterBuildTarget.php', 1354 1354 'HarbormasterBuildTargetPHIDType' => 'applications/harbormaster/phid/HarbormasterBuildTargetPHIDType.php', 1355 1355 'HarbormasterBuildTargetQuery' => 'applications/harbormaster/query/HarbormasterBuildTargetQuery.php', 1356 + 'HarbormasterBuildTargetSearchEngine' => 'applications/harbormaster/query/HarbormasterBuildTargetSearchEngine.php', 1356 1357 'HarbormasterBuildTransaction' => 'applications/harbormaster/storage/HarbormasterBuildTransaction.php', 1357 1358 'HarbormasterBuildTransactionEditor' => 'applications/harbormaster/editor/HarbormasterBuildTransactionEditor.php', 1358 1359 'HarbormasterBuildTransactionQuery' => 'applications/harbormaster/query/HarbormasterBuildTransactionQuery.php', ··· 1433 1434 'HarbormasterStepEditController' => 'applications/harbormaster/controller/HarbormasterStepEditController.php', 1434 1435 'HarbormasterStepViewController' => 'applications/harbormaster/controller/HarbormasterStepViewController.php', 1435 1436 'HarbormasterTargetEngine' => 'applications/harbormaster/engine/HarbormasterTargetEngine.php', 1437 + 'HarbormasterTargetSearchAPIMethod' => 'applications/harbormaster/conduit/HarbormasterTargetSearchAPIMethod.php', 1436 1438 'HarbormasterTargetWorker' => 'applications/harbormaster/worker/HarbormasterTargetWorker.php', 1437 1439 'HarbormasterTestBuildStepGroup' => 'applications/harbormaster/stepgroup/HarbormasterTestBuildStepGroup.php', 1438 1440 'HarbormasterThrowExceptionBuildStep' => 'applications/harbormaster/step/HarbormasterThrowExceptionBuildStep.php', ··· 6832 6834 'HarbormasterDAO', 6833 6835 'PhabricatorPolicyInterface', 6834 6836 'PhabricatorDestructibleInterface', 6837 + 'PhabricatorConduitResultInterface', 6835 6838 ), 6836 6839 'HarbormasterBuildTargetPHIDType' => 'PhabricatorPHIDType', 6837 6840 'HarbormasterBuildTargetQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 6841 + 'HarbormasterBuildTargetSearchEngine' => 'PhabricatorApplicationSearchEngine', 6838 6842 'HarbormasterBuildTransaction' => 'PhabricatorApplicationTransaction', 6839 6843 'HarbormasterBuildTransactionEditor' => 'PhabricatorApplicationTransactionEditor', 6840 6844 'HarbormasterBuildTransactionQuery' => 'PhabricatorApplicationTransactionQuery', ··· 6918 6922 'HarbormasterStepEditController' => 'HarbormasterPlanController', 6919 6923 'HarbormasterStepViewController' => 'HarbormasterPlanController', 6920 6924 'HarbormasterTargetEngine' => 'Phobject', 6925 + 'HarbormasterTargetSearchAPIMethod' => 'PhabricatorSearchEngineAPIMethod', 6921 6926 'HarbormasterTargetWorker' => 'HarbormasterWorker', 6922 6927 'HarbormasterTestBuildStepGroup' => 'HarbormasterBuildStepGroup', 6923 6928 'HarbormasterThrowExceptionBuildStep' => 'HarbormasterBuildStepImplementation',
+18
src/applications/harbormaster/conduit/HarbormasterTargetSearchAPIMethod.php
··· 1 + <?php 2 + 3 + final class HarbormasterTargetSearchAPIMethod 4 + extends PhabricatorSearchEngineAPIMethod { 5 + 6 + public function getAPIMethodName() { 7 + return 'harbormaster.target.search'; 8 + } 9 + 10 + public function newSearchEngine() { 11 + return new HarbormasterBuildTargetSearchEngine(); 12 + } 13 + 14 + public function getMethodSummary() { 15 + return pht('Retrieve information about Harbormaster build targets.'); 16 + } 17 + 18 + }
+73
src/applications/harbormaster/query/HarbormasterBuildTargetSearchEngine.php
··· 1 + <?php 2 + 3 + final class HarbormasterBuildTargetSearchEngine 4 + extends PhabricatorApplicationSearchEngine { 5 + 6 + public function getResultTypeDescription() { 7 + return pht('Harbormaster Build Targets'); 8 + } 9 + 10 + public function getApplicationClassName() { 11 + return 'PhabricatorHarbormasterApplication'; 12 + } 13 + 14 + public function newQuery() { 15 + return new HarbormasterBuildTargetQuery(); 16 + } 17 + 18 + protected function buildCustomSearchFields() { 19 + return array( 20 + id(new PhabricatorSearchDatasourceField()) 21 + ->setLabel(pht('Builds')) 22 + ->setKey('buildPHIDs') 23 + ->setAliases(array('build', 'builds', 'buildPHID')) 24 + ->setDescription( 25 + pht('Search for targets of a given build.')) 26 + ->setDatasource(new HarbormasterBuildPlanDatasource()), 27 + ); 28 + } 29 + 30 + protected function buildQueryFromParameters(array $map) { 31 + $query = $this->newQuery(); 32 + 33 + if ($map['buildPHIDs']) { 34 + $query->withBuildPHIDs($map['buildPHIDs']); 35 + } 36 + 37 + return $query; 38 + } 39 + 40 + protected function getURI($path) { 41 + return '/harbormaster/target/'.$path; 42 + } 43 + 44 + protected function getBuiltinQueryNames() { 45 + return array( 46 + 'all' => pht('All Targets'), 47 + ); 48 + } 49 + 50 + public function buildSavedQueryFromBuiltin($query_key) { 51 + $query = $this->newSavedQuery(); 52 + $query->setQueryKey($query_key); 53 + 54 + switch ($query_key) { 55 + case 'all': 56 + return $query; 57 + } 58 + 59 + return parent::buildSavedQueryFromBuiltin($query_key); 60 + } 61 + 62 + protected function renderResultList( 63 + array $builds, 64 + PhabricatorSavedQuery $query, 65 + array $handles) { 66 + assert_instances_of($builds, 'HarbormasterBuildTarget'); 67 + 68 + // Currently, this only supports the "harbormaster.target.search" 69 + // API method. 70 + throw new PhutilMethodNotImplementedException(); 71 + } 72 + 73 + }
+83 -1
src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php
··· 4 4 extends HarbormasterDAO 5 5 implements 6 6 PhabricatorPolicyInterface, 7 - PhabricatorDestructibleInterface { 7 + PhabricatorDestructibleInterface, 8 + PhabricatorConduitResultInterface { 8 9 9 10 protected $name; 10 11 protected $buildPHID; ··· 409 410 410 411 $this->delete(); 411 412 $this->saveTransaction(); 413 + } 414 + 415 + 416 + /* -( PhabricatorConduitResultInterface )---------------------------------- */ 417 + 418 + 419 + public function getFieldSpecificationsForConduit() { 420 + return array( 421 + id(new PhabricatorConduitSearchFieldSpecification()) 422 + ->setKey('name') 423 + ->setType('string') 424 + ->setDescription(pht('The name of the build target.')), 425 + id(new PhabricatorConduitSearchFieldSpecification()) 426 + ->setKey('buildPHID') 427 + ->setType('phid') 428 + ->setDescription(pht('The build the target is associated with.')), 429 + id(new PhabricatorConduitSearchFieldSpecification()) 430 + ->setKey('buildStepPHID') 431 + ->setType('phid') 432 + ->setDescription(pht('The build step the target runs.')), 433 + id(new PhabricatorConduitSearchFieldSpecification()) 434 + ->setKey('status') 435 + ->setType('map<string, wild>') 436 + ->setDescription(pht('Status for the build target.')), 437 + id(new PhabricatorConduitSearchFieldSpecification()) 438 + ->setKey('epochStarted') 439 + ->setType('epoch?') 440 + ->setDescription( 441 + pht( 442 + 'Epoch timestamp for target start, if the target '. 443 + 'has started.')), 444 + id(new PhabricatorConduitSearchFieldSpecification()) 445 + ->setKey('epochCompleted') 446 + ->setType('epoch?') 447 + ->setDescription( 448 + pht( 449 + 'Epoch timestamp for target completion, if the target '. 450 + 'has completed.')), 451 + id(new PhabricatorConduitSearchFieldSpecification()) 452 + ->setKey('buildGeneration') 453 + ->setType('int') 454 + ->setDescription( 455 + pht( 456 + 'Build generation this target belongs to. When builds '. 457 + 'restart, a new generation with new targets is created.')), 458 + ); 459 + } 460 + 461 + public function getFieldValuesForConduit() { 462 + $status = $this->getTargetStatus(); 463 + 464 + $epoch_started = $this->getDateStarted(); 465 + if ($epoch_started) { 466 + $epoch_started = (int)$epoch_started; 467 + } else { 468 + $epoch_started = null; 469 + } 470 + 471 + $epoch_completed = $this->getDateCompleted(); 472 + if ($epoch_completed) { 473 + $epoch_completed = (int)$epoch_completed; 474 + } else { 475 + $epoch_completed = null; 476 + } 477 + 478 + return array( 479 + 'name' => $this->getName(), 480 + 'buildPHID' => $this->getBuildPHID(), 481 + 'buildStepPHID' => $this->getBuildStepPHID(), 482 + 'status' => array( 483 + 'value' => $status, 484 + 'name' => self::getBuildTargetStatusName($status), 485 + ), 486 + 'epochStarted' => $epoch_started, 487 + 'epochCompleted' => $epoch_completed, 488 + 'buildGeneration' => (int)$this->getBuildGeneration(), 489 + ); 490 + } 491 + 492 + public function getConduitSearchAttachments() { 493 + return array(); 412 494 } 413 495 414 496