Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14078304
D19841.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D19841.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1353,6 +1353,7 @@
'HarbormasterBuildTarget' => 'applications/harbormaster/storage/build/HarbormasterBuildTarget.php',
'HarbormasterBuildTargetPHIDType' => 'applications/harbormaster/phid/HarbormasterBuildTargetPHIDType.php',
'HarbormasterBuildTargetQuery' => 'applications/harbormaster/query/HarbormasterBuildTargetQuery.php',
+ 'HarbormasterBuildTargetSearchEngine' => 'applications/harbormaster/query/HarbormasterBuildTargetSearchEngine.php',
'HarbormasterBuildTransaction' => 'applications/harbormaster/storage/HarbormasterBuildTransaction.php',
'HarbormasterBuildTransactionEditor' => 'applications/harbormaster/editor/HarbormasterBuildTransactionEditor.php',
'HarbormasterBuildTransactionQuery' => 'applications/harbormaster/query/HarbormasterBuildTransactionQuery.php',
@@ -1433,6 +1434,7 @@
'HarbormasterStepEditController' => 'applications/harbormaster/controller/HarbormasterStepEditController.php',
'HarbormasterStepViewController' => 'applications/harbormaster/controller/HarbormasterStepViewController.php',
'HarbormasterTargetEngine' => 'applications/harbormaster/engine/HarbormasterTargetEngine.php',
+ 'HarbormasterTargetSearchAPIMethod' => 'applications/harbormaster/conduit/HarbormasterTargetSearchAPIMethod.php',
'HarbormasterTargetWorker' => 'applications/harbormaster/worker/HarbormasterTargetWorker.php',
'HarbormasterTestBuildStepGroup' => 'applications/harbormaster/stepgroup/HarbormasterTestBuildStepGroup.php',
'HarbormasterThrowExceptionBuildStep' => 'applications/harbormaster/step/HarbormasterThrowExceptionBuildStep.php',
@@ -6832,9 +6834,11 @@
'HarbormasterDAO',
'PhabricatorPolicyInterface',
'PhabricatorDestructibleInterface',
+ 'PhabricatorConduitResultInterface',
),
'HarbormasterBuildTargetPHIDType' => 'PhabricatorPHIDType',
'HarbormasterBuildTargetQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+ 'HarbormasterBuildTargetSearchEngine' => 'PhabricatorApplicationSearchEngine',
'HarbormasterBuildTransaction' => 'PhabricatorApplicationTransaction',
'HarbormasterBuildTransactionEditor' => 'PhabricatorApplicationTransactionEditor',
'HarbormasterBuildTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
@@ -6918,6 +6922,7 @@
'HarbormasterStepEditController' => 'HarbormasterPlanController',
'HarbormasterStepViewController' => 'HarbormasterPlanController',
'HarbormasterTargetEngine' => 'Phobject',
+ 'HarbormasterTargetSearchAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
'HarbormasterTargetWorker' => 'HarbormasterWorker',
'HarbormasterTestBuildStepGroup' => 'HarbormasterBuildStepGroup',
'HarbormasterThrowExceptionBuildStep' => 'HarbormasterBuildStepImplementation',
diff --git a/src/applications/harbormaster/conduit/HarbormasterTargetSearchAPIMethod.php b/src/applications/harbormaster/conduit/HarbormasterTargetSearchAPIMethod.php
new file mode 100644
--- /dev/null
+++ b/src/applications/harbormaster/conduit/HarbormasterTargetSearchAPIMethod.php
@@ -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.');
+ }
+
+}
diff --git a/src/applications/harbormaster/query/HarbormasterBuildTargetSearchEngine.php b/src/applications/harbormaster/query/HarbormasterBuildTargetSearchEngine.php
new file mode 100644
--- /dev/null
+++ b/src/applications/harbormaster/query/HarbormasterBuildTargetSearchEngine.php
@@ -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();
+ }
+
+}
diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php b/src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php
--- a/src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php
+++ b/src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php
@@ -4,7 +4,8 @@
extends HarbormasterDAO
implements
PhabricatorPolicyInterface,
- PhabricatorDestructibleInterface {
+ PhabricatorDestructibleInterface,
+ PhabricatorConduitResultInterface {
protected $name;
protected $buildPHID;
@@ -412,4 +413,85 @@
}
+/* -( 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();
+ }
+
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 3:09 AM (16 h, 44 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6776957
Default Alt Text
D19841.diff (8 KB)
Attached To
Mode
D19841: Add support for "harbormaster.target.search"
Attached
Detach File
Event Timeline
Log In to Comment