1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-28 17:52:43 +01:00
phorge-phorge/src/applications/harbormaster/step/HarbormasterDrydockCommandBuildStepImplementation.php
epriestley 4d5278af11 Put Drydock build steps into their own group in Harbormaster
Summary: Ref T9252. Move these into a new "Drydock" group.

Test Plan: Clicked "Add Build Step", saw Drydock steps in a Drydock group.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9252

Differential Revision: https://secure.phabricator.com/D14237
2015-10-05 15:59:35 -07:00

90 lines
2.2 KiB
PHP

<?php
final class HarbormasterDrydockCommandBuildStepImplementation
extends HarbormasterBuildStepImplementation {
public function getName() {
return pht('Drydock: Run Command');
}
public function getGenericDescription() {
return pht('Run a command on Drydock resource.');
}
public function getBuildStepGroupKey() {
return HarbormasterDrydockBuildStepGroup::GROUPKEY;
}
public function getDescription() {
return pht(
'Run command %s on %s.',
$this->formatSettingForDescription('command'),
$this->formatSettingForDescription('artifact'));
}
public function execute(
HarbormasterBuild $build,
HarbormasterBuildTarget $build_target) {
$viewer = PhabricatorUser::getOmnipotentUser();
$settings = $this->getSettings();
$variables = $build_target->getVariables();
$artifact = $build_target->loadArtifact($settings['artifact']);
$impl = $artifact->getArtifactImplementation();
$lease = $impl->loadArtifactLease($viewer);
// TODO: Require active lease.
$command = $this->mergeVariables(
'vcsprintf',
$settings['command'],
$variables);
$interface = $lease->getInterface(DrydockCommandInterface::INTERFACE_TYPE);
$exec_future = $interface->getExecFuture('%C', $command);
$harbor_future = id(new HarbormasterExecFuture())
->setFuture($exec_future)
->setLogs(
$build_target->newLog('remote', 'stdout'),
$build_target->newLog('remote', 'stderr'));
$this->resolveFutures(
$build,
$build_target,
array($harbor_future));
list($err) = $harbor_future->resolve();
if ($err) {
throw new HarbormasterBuildFailureException();
}
}
public function getArtifactInputs() {
return array(
array(
'name' => pht('Drydock Lease'),
'key' => $this->getSetting('artifact'),
'type' => HarbormasterWorkingCopyArtifact::ARTIFACTCONST,
),
);
}
public function getFieldSpecifications() {
return array(
'command' => array(
'name' => pht('Command'),
'type' => 'text',
'required' => true,
),
'artifact' => array(
'name' => pht('Drydock Lease'),
'type' => 'text',
'required' => true,
),
);
}
}