mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
Write a trivial log when starting a repository operation
Summary: Depends on D19672. Ref T13197. See PHI873. This writes a trivial log when we begin acting on a working copy and makes it look reasonable in the UI. This is mostly just to prove that logging works properly. Test Plan: {F5887697} Reviewers: amckinley Reviewed By: amckinley Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13197 Differential Revision: https://secure.phabricator.com/D19673
This commit is contained in:
parent
92bcf85974
commit
a7e060f062
11 changed files with 150 additions and 15 deletions
|
@ -1168,6 +1168,7 @@ phutil_register_library_map(array(
|
|||
'DrydockManagementUpdateResourceWorkflow' => 'applications/drydock/management/DrydockManagementUpdateResourceWorkflow.php',
|
||||
'DrydockManagementWorkflow' => 'applications/drydock/management/DrydockManagementWorkflow.php',
|
||||
'DrydockObjectAuthorizationView' => 'applications/drydock/view/DrydockObjectAuthorizationView.php',
|
||||
'DrydockOperationWorkLogType' => 'applications/drydock/logtype/DrydockOperationWorkLogType.php',
|
||||
'DrydockQuery' => 'applications/drydock/query/DrydockQuery.php',
|
||||
'DrydockRepositoryOperation' => 'applications/drydock/storage/DrydockRepositoryOperation.php',
|
||||
'DrydockRepositoryOperationController' => 'applications/drydock/controller/DrydockRepositoryOperationController.php',
|
||||
|
@ -6575,6 +6576,7 @@ phutil_register_library_map(array(
|
|||
'DrydockManagementUpdateResourceWorkflow' => 'DrydockManagementWorkflow',
|
||||
'DrydockManagementWorkflow' => 'PhabricatorManagementWorkflow',
|
||||
'DrydockObjectAuthorizationView' => 'AphrontView',
|
||||
'DrydockOperationWorkLogType' => 'DrydockLogType',
|
||||
'DrydockQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'DrydockRepositoryOperation' => array(
|
||||
'DrydockDAO',
|
||||
|
|
|
@ -58,8 +58,11 @@ final class DrydockBlueprintViewController extends DrydockBlueprintController {
|
|||
$log_query = id(new DrydockLogQuery())
|
||||
->withBlueprintPHIDs(array($blueprint->getPHID()));
|
||||
|
||||
$log_table = $this->buildLogTable($log_query)
|
||||
->setHideBlueprints(true);
|
||||
|
||||
$logs = $this->buildLogBox(
|
||||
$log_query,
|
||||
$log_table,
|
||||
$this->getApplicationURI("blueprint/{$id}/logs/query/all/"));
|
||||
|
||||
$view = id(new PHUITwoColumnView())
|
||||
|
|
|
@ -79,7 +79,7 @@ abstract class DrydockController extends PhabricatorController {
|
|||
->addRawContent($table);
|
||||
}
|
||||
|
||||
protected function buildLogBox(DrydockLogQuery $query, $all_uri) {
|
||||
protected function buildLogTable(DrydockLogQuery $query) {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$logs = $query
|
||||
|
@ -89,9 +89,12 @@ abstract class DrydockController extends PhabricatorController {
|
|||
|
||||
$log_table = id(new DrydockLogListView())
|
||||
->setUser($viewer)
|
||||
->setLogs($logs)
|
||||
->render();
|
||||
->setLogs($logs);
|
||||
|
||||
return $log_table;
|
||||
}
|
||||
|
||||
protected function buildLogBox(DrydockLogListView $log_table, $all_uri) {
|
||||
$log_header = id(new PHUIHeaderView())
|
||||
->setHeader(pht('Logs'))
|
||||
->addActionLink(
|
||||
|
|
|
@ -43,8 +43,11 @@ final class DrydockLeaseViewController extends DrydockLeaseController {
|
|||
$log_query = id(new DrydockLogQuery())
|
||||
->withLeasePHIDs(array($lease->getPHID()));
|
||||
|
||||
$log_table = $this->buildLogTable($log_query)
|
||||
->setHideLeases(true);
|
||||
|
||||
$logs = $this->buildLogBox(
|
||||
$log_query,
|
||||
$log_table,
|
||||
$this->getApplicationURI("lease/{$id}/logs/query/all/"));
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
|
|
|
@ -50,8 +50,11 @@ final class DrydockRepositoryOperationViewController
|
|||
$log_query = id(new DrydockLogQuery())
|
||||
->withOperationPHIDs(array($operation->getPHID()));
|
||||
|
||||
$log_table = $this->buildLogTable($log_query)
|
||||
->setHideOperations(true);
|
||||
|
||||
$logs = $this->buildLogBox(
|
||||
$log_query,
|
||||
$log_table,
|
||||
$this->getApplicationURI("operation/{$id}/logs/query/all/"));
|
||||
|
||||
$view = id(new PHUITwoColumnView())
|
||||
|
|
|
@ -48,8 +48,11 @@ final class DrydockResourceViewController extends DrydockResourceController {
|
|||
$log_query = id(new DrydockLogQuery())
|
||||
->withResourcePHIDs(array($resource->getPHID()));
|
||||
|
||||
$log_box = $this->buildLogBox(
|
||||
$log_query,
|
||||
$log_table = $this->buildLogTable($log_query)
|
||||
->setHideResources(true);
|
||||
|
||||
$logs = $this->buildLogBox(
|
||||
$log_table,
|
||||
$this->getApplicationURI("resource/{$id}/logs/query/all/"));
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
|
@ -86,11 +89,12 @@ final class DrydockResourceViewController extends DrydockResourceController {
|
|||
$view = id(new PHUITwoColumnView())
|
||||
->setHeader($header)
|
||||
->setCurtain($curtain)
|
||||
->setMainColumn(array(
|
||||
$object_box,
|
||||
$lease_box,
|
||||
$log_box,
|
||||
));
|
||||
->setMainColumn(
|
||||
array(
|
||||
$object_box,
|
||||
$lease_box,
|
||||
$logs,
|
||||
));
|
||||
|
||||
return $this->newPage()
|
||||
->setTitle($title)
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
final class DrydockOperationWorkLogType extends DrydockLogType {
|
||||
|
||||
const LOGCONST = 'core.operation.work';
|
||||
|
||||
public function getLogTypeName() {
|
||||
return pht('Started Work');
|
||||
}
|
||||
|
||||
public function getLogTypeIcon(array $data) {
|
||||
return 'fa-check green';
|
||||
}
|
||||
|
||||
public function renderLog(array $data) {
|
||||
return pht('Started this operation in a working copy.');
|
||||
}
|
||||
|
||||
}
|
|
@ -5,7 +5,7 @@ final class DrydockRepositoryOperationPHIDType extends PhabricatorPHIDType {
|
|||
const TYPECONST = 'DRYO';
|
||||
|
||||
public function getTypeName() {
|
||||
return pht('Drydock Repository Operation');
|
||||
return pht('Repository Operation');
|
||||
}
|
||||
|
||||
public function newObject() {
|
||||
|
@ -33,7 +33,7 @@ final class DrydockRepositoryOperationPHIDType extends PhabricatorPHIDType {
|
|||
$operation = $objects[$phid];
|
||||
$id = $operation->getID();
|
||||
|
||||
$handle->setName(pht('Drydock Repository Operation %d', $id));
|
||||
$handle->setName(pht('Repository Operation %d', $id));
|
||||
$handle->setURI("/drydock/operation/{$id}/");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ final class DrydockRepositoryOperation extends DrydockDAO
|
|||
private $repository = self::ATTACHABLE;
|
||||
private $object = self::ATTACHABLE;
|
||||
private $implementation = self::ATTACHABLE;
|
||||
private $workingCopyLease = self::ATTACHABLE;
|
||||
|
||||
public static function initializeNewOperation(
|
||||
DrydockRepositoryOperationType $op) {
|
||||
|
@ -90,6 +91,19 @@ final class DrydockRepositoryOperation extends DrydockDAO
|
|||
return $this->implementation;
|
||||
}
|
||||
|
||||
public function getWorkingCopyLease() {
|
||||
return $this->assertAttached($this->workingCopyLease);
|
||||
}
|
||||
|
||||
public function attachWorkingCopyLease(DrydockLease $lease) {
|
||||
$this->workingCopyLease = $lease;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function hasWorkingCopyLease() {
|
||||
return ($this->workingCopyLease !== self::ATTACHABLE);
|
||||
}
|
||||
|
||||
public function getProperty($key, $default = null) {
|
||||
return idx($this->properties, $key, $default);
|
||||
}
|
||||
|
@ -189,6 +203,29 @@ final class DrydockRepositoryOperation extends DrydockDAO
|
|||
return $this->getProperty('exec.workingcopy.error');
|
||||
}
|
||||
|
||||
public function logEvent($type, array $data = array()) {
|
||||
$log = id(new DrydockLog())
|
||||
->setEpoch(PhabricatorTime::getNow())
|
||||
->setType($type)
|
||||
->setData($data);
|
||||
|
||||
$log->setOperationPHID($this->getPHID());
|
||||
|
||||
if ($this->hasWorkingCopyLease()) {
|
||||
$lease = $this->getWorkingCopyLease();
|
||||
$log->setLeasePHID($lease->getPHID());
|
||||
|
||||
$resource_phid = $lease->getResourcePHID();
|
||||
if ($resource_phid) {
|
||||
$resource = $lease->getResource();
|
||||
|
||||
$log->setResourcePHID($resource->getPHID());
|
||||
$log->setBlueprintPHID($resource->getBlueprintPHID());
|
||||
}
|
||||
}
|
||||
|
||||
return $log->save();
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||
|
|
|
@ -3,6 +3,46 @@
|
|||
final class DrydockLogListView extends AphrontView {
|
||||
|
||||
private $logs;
|
||||
private $hideBlueprints;
|
||||
private $hideResources;
|
||||
private $hideLeases;
|
||||
private $hideOperations;
|
||||
|
||||
public function setHideBlueprints($hide_blueprints) {
|
||||
$this->hideBlueprints = $hide_blueprints;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHideBlueprints() {
|
||||
return $this->hideBlueprints;
|
||||
}
|
||||
|
||||
public function setHideResources($hide_resources) {
|
||||
$this->hideResources = $hide_resources;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHideResources() {
|
||||
return $this->hideResources;
|
||||
}
|
||||
|
||||
public function setHideLeases($hide_leases) {
|
||||
$this->hideLeases = $hide_leases;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHideLeases() {
|
||||
return $this->hideLeases;
|
||||
}
|
||||
|
||||
public function setHideOperations($hide_operations) {
|
||||
$this->hideOperations = $hide_operations;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHideOperations() {
|
||||
return $this->hideOperations;
|
||||
}
|
||||
|
||||
public function setLogs(array $logs) {
|
||||
assert_instances_of($logs, 'DrydockLog');
|
||||
|
@ -41,6 +81,13 @@ final class DrydockLogListView extends AphrontView {
|
|||
$lease = null;
|
||||
}
|
||||
|
||||
$operation_phid = $log->getOperationPHID();
|
||||
if ($operation_phid) {
|
||||
$operation = $viewer->renderHandle($operation_phid);
|
||||
} else {
|
||||
$operation = null;
|
||||
}
|
||||
|
||||
if ($log->isComplete()) {
|
||||
$type_key = $log->getType();
|
||||
if (isset($types[$type_key])) {
|
||||
|
@ -72,6 +119,7 @@ final class DrydockLogListView extends AphrontView {
|
|||
$blueprint,
|
||||
$resource,
|
||||
$lease,
|
||||
$operation,
|
||||
id(new PHUIIconView())->setIcon($icon),
|
||||
$type,
|
||||
$data,
|
||||
|
@ -86,16 +134,25 @@ final class DrydockLogListView extends AphrontView {
|
|||
pht('Blueprint'),
|
||||
pht('Resource'),
|
||||
pht('Lease'),
|
||||
pht('Operation'),
|
||||
null,
|
||||
pht('Type'),
|
||||
pht('Data'),
|
||||
pht('Date'),
|
||||
))
|
||||
->setColumnVisibility(
|
||||
array(
|
||||
!$this->getHideBlueprints(),
|
||||
!$this->getHideResources(),
|
||||
!$this->getHideLeases(),
|
||||
!$this->getHideOperations(),
|
||||
))
|
||||
->setColumnClasses(
|
||||
array(
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'icon',
|
||||
'',
|
||||
'wide',
|
||||
|
|
|
@ -59,6 +59,10 @@ final class DrydockRepositoryOperationUpdateWorker
|
|||
// No matter what happens here, destroy the lease away once we're done.
|
||||
$lease->setReleaseOnDestruction(true);
|
||||
|
||||
$operation->attachWorkingCopyLease($lease);
|
||||
|
||||
$operation->logEvent(DrydockOperationWorkLogType::LOGCONST);
|
||||
|
||||
$operation->applyOperation($interface);
|
||||
|
||||
} catch (PhabricatorWorkerYieldException $ex) {
|
||||
|
|
Loading…
Reference in a new issue