mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-25 15:00:58 +01:00
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
This commit is contained in:
parent
2f11001f6e
commit
01c7be059d
4 changed files with 179 additions and 1 deletions
|
@ -1353,6 +1353,7 @@ phutil_register_library_map(array(
|
||||||
'HarbormasterBuildTarget' => 'applications/harbormaster/storage/build/HarbormasterBuildTarget.php',
|
'HarbormasterBuildTarget' => 'applications/harbormaster/storage/build/HarbormasterBuildTarget.php',
|
||||||
'HarbormasterBuildTargetPHIDType' => 'applications/harbormaster/phid/HarbormasterBuildTargetPHIDType.php',
|
'HarbormasterBuildTargetPHIDType' => 'applications/harbormaster/phid/HarbormasterBuildTargetPHIDType.php',
|
||||||
'HarbormasterBuildTargetQuery' => 'applications/harbormaster/query/HarbormasterBuildTargetQuery.php',
|
'HarbormasterBuildTargetQuery' => 'applications/harbormaster/query/HarbormasterBuildTargetQuery.php',
|
||||||
|
'HarbormasterBuildTargetSearchEngine' => 'applications/harbormaster/query/HarbormasterBuildTargetSearchEngine.php',
|
||||||
'HarbormasterBuildTransaction' => 'applications/harbormaster/storage/HarbormasterBuildTransaction.php',
|
'HarbormasterBuildTransaction' => 'applications/harbormaster/storage/HarbormasterBuildTransaction.php',
|
||||||
'HarbormasterBuildTransactionEditor' => 'applications/harbormaster/editor/HarbormasterBuildTransactionEditor.php',
|
'HarbormasterBuildTransactionEditor' => 'applications/harbormaster/editor/HarbormasterBuildTransactionEditor.php',
|
||||||
'HarbormasterBuildTransactionQuery' => 'applications/harbormaster/query/HarbormasterBuildTransactionQuery.php',
|
'HarbormasterBuildTransactionQuery' => 'applications/harbormaster/query/HarbormasterBuildTransactionQuery.php',
|
||||||
|
@ -1433,6 +1434,7 @@ phutil_register_library_map(array(
|
||||||
'HarbormasterStepEditController' => 'applications/harbormaster/controller/HarbormasterStepEditController.php',
|
'HarbormasterStepEditController' => 'applications/harbormaster/controller/HarbormasterStepEditController.php',
|
||||||
'HarbormasterStepViewController' => 'applications/harbormaster/controller/HarbormasterStepViewController.php',
|
'HarbormasterStepViewController' => 'applications/harbormaster/controller/HarbormasterStepViewController.php',
|
||||||
'HarbormasterTargetEngine' => 'applications/harbormaster/engine/HarbormasterTargetEngine.php',
|
'HarbormasterTargetEngine' => 'applications/harbormaster/engine/HarbormasterTargetEngine.php',
|
||||||
|
'HarbormasterTargetSearchAPIMethod' => 'applications/harbormaster/conduit/HarbormasterTargetSearchAPIMethod.php',
|
||||||
'HarbormasterTargetWorker' => 'applications/harbormaster/worker/HarbormasterTargetWorker.php',
|
'HarbormasterTargetWorker' => 'applications/harbormaster/worker/HarbormasterTargetWorker.php',
|
||||||
'HarbormasterTestBuildStepGroup' => 'applications/harbormaster/stepgroup/HarbormasterTestBuildStepGroup.php',
|
'HarbormasterTestBuildStepGroup' => 'applications/harbormaster/stepgroup/HarbormasterTestBuildStepGroup.php',
|
||||||
'HarbormasterThrowExceptionBuildStep' => 'applications/harbormaster/step/HarbormasterThrowExceptionBuildStep.php',
|
'HarbormasterThrowExceptionBuildStep' => 'applications/harbormaster/step/HarbormasterThrowExceptionBuildStep.php',
|
||||||
|
@ -6832,9 +6834,11 @@ phutil_register_library_map(array(
|
||||||
'HarbormasterDAO',
|
'HarbormasterDAO',
|
||||||
'PhabricatorPolicyInterface',
|
'PhabricatorPolicyInterface',
|
||||||
'PhabricatorDestructibleInterface',
|
'PhabricatorDestructibleInterface',
|
||||||
|
'PhabricatorConduitResultInterface',
|
||||||
),
|
),
|
||||||
'HarbormasterBuildTargetPHIDType' => 'PhabricatorPHIDType',
|
'HarbormasterBuildTargetPHIDType' => 'PhabricatorPHIDType',
|
||||||
'HarbormasterBuildTargetQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'HarbormasterBuildTargetQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
|
'HarbormasterBuildTargetSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||||
'HarbormasterBuildTransaction' => 'PhabricatorApplicationTransaction',
|
'HarbormasterBuildTransaction' => 'PhabricatorApplicationTransaction',
|
||||||
'HarbormasterBuildTransactionEditor' => 'PhabricatorApplicationTransactionEditor',
|
'HarbormasterBuildTransactionEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
'HarbormasterBuildTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
'HarbormasterBuildTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
||||||
|
@ -6918,6 +6922,7 @@ phutil_register_library_map(array(
|
||||||
'HarbormasterStepEditController' => 'HarbormasterPlanController',
|
'HarbormasterStepEditController' => 'HarbormasterPlanController',
|
||||||
'HarbormasterStepViewController' => 'HarbormasterPlanController',
|
'HarbormasterStepViewController' => 'HarbormasterPlanController',
|
||||||
'HarbormasterTargetEngine' => 'Phobject',
|
'HarbormasterTargetEngine' => 'Phobject',
|
||||||
|
'HarbormasterTargetSearchAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
|
||||||
'HarbormasterTargetWorker' => 'HarbormasterWorker',
|
'HarbormasterTargetWorker' => 'HarbormasterWorker',
|
||||||
'HarbormasterTestBuildStepGroup' => 'HarbormasterBuildStepGroup',
|
'HarbormasterTestBuildStepGroup' => 'HarbormasterBuildStepGroup',
|
||||||
'HarbormasterThrowExceptionBuildStep' => 'HarbormasterBuildStepImplementation',
|
'HarbormasterThrowExceptionBuildStep' => 'HarbormasterBuildStepImplementation',
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class HarbormasterTargetSearchAPIMethod
|
||||||
|
extends PhabricatorSearchEngineAPIMethod {
|
||||||
|
|
||||||
|
public function getAPIMethodName() {
|
||||||
|
return 'harbormaster.target.search';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function newSearchEngine() {
|
||||||
|
return new HarbormasterBuildTargetSearchEngine();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMethodSummary() {
|
||||||
|
return pht('Retrieve information about Harbormaster build targets.');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class HarbormasterBuildTargetSearchEngine
|
||||||
|
extends PhabricatorApplicationSearchEngine {
|
||||||
|
|
||||||
|
public function getResultTypeDescription() {
|
||||||
|
return pht('Harbormaster Build Targets');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getApplicationClassName() {
|
||||||
|
return 'PhabricatorHarbormasterApplication';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function newQuery() {
|
||||||
|
return new HarbormasterBuildTargetQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildCustomSearchFields() {
|
||||||
|
return array(
|
||||||
|
id(new PhabricatorSearchDatasourceField())
|
||||||
|
->setLabel(pht('Builds'))
|
||||||
|
->setKey('buildPHIDs')
|
||||||
|
->setAliases(array('build', 'builds', 'buildPHID'))
|
||||||
|
->setDescription(
|
||||||
|
pht('Search for targets of a given build.'))
|
||||||
|
->setDatasource(new HarbormasterBuildPlanDatasource()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildQueryFromParameters(array $map) {
|
||||||
|
$query = $this->newQuery();
|
||||||
|
|
||||||
|
if ($map['buildPHIDs']) {
|
||||||
|
$query->withBuildPHIDs($map['buildPHIDs']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getURI($path) {
|
||||||
|
return '/harbormaster/target/'.$path;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getBuiltinQueryNames() {
|
||||||
|
return array(
|
||||||
|
'all' => pht('All Targets'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildSavedQueryFromBuiltin($query_key) {
|
||||||
|
$query = $this->newSavedQuery();
|
||||||
|
$query->setQueryKey($query_key);
|
||||||
|
|
||||||
|
switch ($query_key) {
|
||||||
|
case 'all':
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function renderResultList(
|
||||||
|
array $builds,
|
||||||
|
PhabricatorSavedQuery $query,
|
||||||
|
array $handles) {
|
||||||
|
assert_instances_of($builds, 'HarbormasterBuildTarget');
|
||||||
|
|
||||||
|
// Currently, this only supports the "harbormaster.target.search"
|
||||||
|
// API method.
|
||||||
|
throw new PhutilMethodNotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -4,7 +4,8 @@ final class HarbormasterBuildTarget
|
||||||
extends HarbormasterDAO
|
extends HarbormasterDAO
|
||||||
implements
|
implements
|
||||||
PhabricatorPolicyInterface,
|
PhabricatorPolicyInterface,
|
||||||
PhabricatorDestructibleInterface {
|
PhabricatorDestructibleInterface,
|
||||||
|
PhabricatorConduitResultInterface {
|
||||||
|
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $buildPHID;
|
protected $buildPHID;
|
||||||
|
@ -412,4 +413,85 @@ final class HarbormasterBuildTarget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -( PhabricatorConduitResultInterface )---------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
public function getFieldSpecificationsForConduit() {
|
||||||
|
return array(
|
||||||
|
id(new PhabricatorConduitSearchFieldSpecification())
|
||||||
|
->setKey('name')
|
||||||
|
->setType('string')
|
||||||
|
->setDescription(pht('The name of the build target.')),
|
||||||
|
id(new PhabricatorConduitSearchFieldSpecification())
|
||||||
|
->setKey('buildPHID')
|
||||||
|
->setType('phid')
|
||||||
|
->setDescription(pht('The build the target is associated with.')),
|
||||||
|
id(new PhabricatorConduitSearchFieldSpecification())
|
||||||
|
->setKey('buildStepPHID')
|
||||||
|
->setType('phid')
|
||||||
|
->setDescription(pht('The build step the target runs.')),
|
||||||
|
id(new PhabricatorConduitSearchFieldSpecification())
|
||||||
|
->setKey('status')
|
||||||
|
->setType('map<string, wild>')
|
||||||
|
->setDescription(pht('Status for the build target.')),
|
||||||
|
id(new PhabricatorConduitSearchFieldSpecification())
|
||||||
|
->setKey('epochStarted')
|
||||||
|
->setType('epoch?')
|
||||||
|
->setDescription(
|
||||||
|
pht(
|
||||||
|
'Epoch timestamp for target start, if the target '.
|
||||||
|
'has started.')),
|
||||||
|
id(new PhabricatorConduitSearchFieldSpecification())
|
||||||
|
->setKey('epochCompleted')
|
||||||
|
->setType('epoch?')
|
||||||
|
->setDescription(
|
||||||
|
pht(
|
||||||
|
'Epoch timestamp for target completion, if the target '.
|
||||||
|
'has completed.')),
|
||||||
|
id(new PhabricatorConduitSearchFieldSpecification())
|
||||||
|
->setKey('buildGeneration')
|
||||||
|
->setType('int')
|
||||||
|
->setDescription(
|
||||||
|
pht(
|
||||||
|
'Build generation this target belongs to. When builds '.
|
||||||
|
'restart, a new generation with new targets is created.')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFieldValuesForConduit() {
|
||||||
|
$status = $this->getTargetStatus();
|
||||||
|
|
||||||
|
$epoch_started = $this->getDateStarted();
|
||||||
|
if ($epoch_started) {
|
||||||
|
$epoch_started = (int)$epoch_started;
|
||||||
|
} else {
|
||||||
|
$epoch_started = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$epoch_completed = $this->getDateCompleted();
|
||||||
|
if ($epoch_completed) {
|
||||||
|
$epoch_completed = (int)$epoch_completed;
|
||||||
|
} else {
|
||||||
|
$epoch_completed = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'name' => $this->getName(),
|
||||||
|
'buildPHID' => $this->getBuildPHID(),
|
||||||
|
'buildStepPHID' => $this->getBuildStepPHID(),
|
||||||
|
'status' => array(
|
||||||
|
'value' => $status,
|
||||||
|
'name' => self::getBuildTargetStatusName($status),
|
||||||
|
),
|
||||||
|
'epochStarted' => $epoch_started,
|
||||||
|
'epochCompleted' => $epoch_completed,
|
||||||
|
'buildGeneration' => (int)$this->getBuildGeneration(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getConduitSearchAttachments() {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue