3 abstract class HarbormasterDrydockLeaseArtifact
4 extends HarbormasterArtifact
{
6 public function getArtifactParameterSpecification() {
8 'drydockLeasePHID' => 'string',
12 public function getArtifactParameterDescriptions() {
14 'drydockLeasePHID' => pht(
15 'Drydock working copy lease to create an artifact from.'),
19 public function getArtifactDataExample() {
21 'drydockLeasePHID' => 'PHID-DRYL-abcdefghijklmnopqrst',
25 public function renderArtifactSummary(PhabricatorUser
$viewer) {
26 $artifact = $this->getBuildArtifact();
27 $lease_phid = $artifact->getProperty('drydockLeasePHID');
28 return $viewer->renderHandle($lease_phid);
31 public function willCreateArtifact(PhabricatorUser
$actor) {
32 // We don't load the lease here because it's expected that artifacts are
33 // created before leases actually exist. This guarantees that the leases
34 // will be cleaned up.
37 public function loadArtifactLease(PhabricatorUser
$viewer) {
38 $artifact = $this->getBuildArtifact();
39 $lease_phid = $artifact->getProperty('drydockLeasePHID');
41 $lease = id(new DrydockLeaseQuery())
43 ->withPHIDs(array($lease_phid))
48 'Drydock lease PHID "%s" does not correspond to a valid lease.',
55 public function releaseArtifact(PhabricatorUser
$actor) {
57 $lease = $this->loadArtifactLease($actor);
58 } catch (Exception
$ex) {
59 // If we can't load the lease, treat it as already released. Artifacts
60 // are generated before leases are queued, so it's possible to arrive
61 // here under normal conditions.
65 if (!$lease->canRelease()) {
69 $author_phid = $actor->getPHID();
71 $author_phid = id(new PhabricatorHarbormasterApplication())->getPHID();
74 $command = DrydockCommand
::initializeNewCommand($actor)
75 ->setTargetPHID($lease->getPHID())
76 ->setAuthorPHID($author_phid)
77 ->setCommand(DrydockCommand
::COMMAND_RELEASE
)
80 $lease->scheduleUpdate();