Differential D13984 Diff 33743 src/applications/harbormaster/step/HarbormasterLeaseHostBuildStepImplementation.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/step/HarbormasterLeaseHostBuildStepImplementation.php
| Show All 26 Lines | public function execute( | ||||
| // that lease is active instead of creating a new one. | // that lease is active instead of creating a new one. | ||||
| $artifacts = id(new HarbormasterBuildArtifactQuery()) | $artifacts = id(new HarbormasterBuildArtifactQuery()) | ||||
| ->setViewer(PhabricatorUser::getOmnipotentUser()) | ->setViewer(PhabricatorUser::getOmnipotentUser()) | ||||
| ->withBuildTargetPHIDs(array($build_target->getPHID())) | ->withBuildTargetPHIDs(array($build_target->getPHID())) | ||||
| ->execute(); | ->execute(); | ||||
| $artifact = count($artifacts) > 0 ? head($artifacts) : null; | $artifact = count($artifacts) > 0 ? head($artifacts) : null; | ||||
| if ($artifact === null) { | if ($artifact === null) { | ||||
| $custom_attributes = DrydockCustomAttributes::parse( | |||||
| idx($settings, 'attributes', '')); | |||||
| // Create the lease. | // Create the lease. | ||||
| $lease = id(new DrydockLease()) | $lease = id(new DrydockLease()) | ||||
| ->setResourceType('host') | ->setResourceType('host') | ||||
| ->setAttributes( | ->setAttributes( | ||||
| array( | array( | ||||
| 'platform' => $settings['platform'], | 'platform' => $settings['platform'], | ||||
| )) | ) + $custom_attributes) | ||||
| ->queueForActivation(); | ->queueForActivation(); | ||||
| // Create the associated artifact. | // Create the associated artifact. | ||||
| $artifact = $build_target->createArtifact( | $artifact = $build_target->createArtifact( | ||||
| PhabricatorUser::getOmnipotentUser(), | PhabricatorUser::getOmnipotentUser(), | ||||
| $settings['name'], | $settings['name'], | ||||
| HarbormasterHostArtifact::ARTIFACTCONST, | HarbormasterHostArtifact::ARTIFACTCONST, | ||||
| array( | array( | ||||
| Show All 32 Lines | return array( | ||||
| 'type' => 'text', | 'type' => 'text', | ||||
| 'required' => true, | 'required' => true, | ||||
| ), | ), | ||||
| 'platform' => array( | 'platform' => array( | ||||
| 'name' => pht('Platform'), | 'name' => pht('Platform'), | ||||
| 'type' => 'text', | 'type' => 'text', | ||||
| 'required' => true, | 'required' => true, | ||||
| ), | ), | ||||
| 'attributes' => array( | |||||
| 'name' => pht('Required Attributes'), | |||||
| 'type' => 'textarea', | |||||
| 'caption' => pht( | |||||
| 'A newline separated list of required host attributes. Each '. | |||||
| 'attribute should be specified in a key=value format.'), | |||||
| 'monospace' => true, | |||||
| ), | |||||
| ); | ); | ||||
| } | } | ||||
| } | } | ||||