Differential D12783 Diff 31664 src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php
- This file was added.
<?php | |||||
final class HarbormasterLeaseWorkingCopyBuildStepImplementation | |||||
extends HarbormasterBuildStepImplementation { | |||||
public function getName() { | |||||
return pht('Lease Working Copy'); | |||||
} | |||||
public function getGenericDescription() { | |||||
return pht( | |||||
'Obtain a lease on a Drydock working copy of the '. | |||||
'current buildable for performing builds.'); | |||||
} | |||||
public function execute( | |||||
HarbormasterBuild $build, | |||||
HarbormasterBuildTarget $build_target) { | |||||
$settings = $this->getSettings(); | |||||
$custom_attributes = DrydockCustomAttributes::parse( | |||||
$settings['attributes']); | |||||
// Create the lease. | |||||
$lease = id(new DrydockLease()) | |||||
->setResourceType('working-copy') | |||||
->setAttributes( | |||||
array( | |||||
'platform' => $settings['platform'], | |||||
'buildablePHID' => $build->getBuildablePHID(), | |||||
) + $custom_attributes) | |||||
->queueForActivation(); | |||||
// Create the associated artifact. | |||||
$artifact = $build->createArtifact( | |||||
$build_target, | |||||
$settings['name'], | |||||
HarbormasterBuildArtifact::TYPE_HOST); | |||||
$artifact->setArtifactData(array( | |||||
'drydock-lease' => $lease->getID(), | |||||
)); | |||||
$artifact->save(); | |||||
// Wait until the lease is fulfilled. | |||||
// TODO: This will throw an exception if the lease can't be fulfilled; | |||||
// we should treat that as build failure not build error. | |||||
$lease->waitUntilActive(); | |||||
} | |||||
public function getArtifactOutputs() { | |||||
return array( | |||||
array( | |||||
'name' => pht('Leased Working Copy'), | |||||
'key' => $this->getSetting('name'), | |||||
'type' => HarbormasterBuildArtifact::TYPE_HOST, | |||||
), | |||||
); | |||||
} | |||||
public function getFieldSpecifications() { | |||||
return array( | |||||
'name' => array( | |||||
'name' => pht('Artifact Name'), | |||||
'type' => 'text', | |||||
'required' => true, | |||||
), | |||||
'platform' => array( | |||||
'name' => pht('Host Platform'), | |||||
'type' => 'text', | |||||
'required' => true, | |||||
), | |||||
'attributes' => array( | |||||
'name' => pht('Required Attributes'), | |||||
'type' => 'textarea', | |||||
'caption' => pht( | |||||
'A newline separated list of required working copy attributes. '. | |||||
'Each attribute should be specified in a key=value format.'), | |||||
'monospace' => true, | |||||
), | |||||
); | |||||
} | |||||
} |