Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14406479
D21796.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D21796.diff
View Options
diff --git a/src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php b/src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php
--- a/src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php
+++ b/src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php
@@ -135,14 +135,7 @@
->setAllowedBlueprintPHIDs($blueprint_phids);
$resource->setAttribute('host.leasePHID', $host_lease->getPHID());
- $map = $lease->getAttribute('repositories.map');
- foreach ($map as $key => $value) {
- $map[$key] = array_select_keys(
- $value,
- array(
- 'phid',
- ));
- }
+ $map = $this->getWorkingCopyRepositoryMap($lease);
$resource->setAttribute('repositories.map', $map);
$slot_lock = $this->getConcurrentResourceLimitSlotLock($blueprint);
@@ -157,6 +150,44 @@
return $resource;
}
+ private function getWorkingCopyRepositoryMap(DrydockLease $lease) {
+ $attribute = 'repositories.map';
+ $map = $lease->getAttribute($attribute);
+
+ // TODO: Leases should validate their attributes more formally.
+
+ if (!is_array($map) || !$map) {
+ $message = array();
+ if ($map === null) {
+ $message[] = pht(
+ 'Working copy lease is missing required attribute "%s".',
+ $attribute);
+ } else {
+ $message[] = pht(
+ 'Working copy lease has invalid attribute "%s".',
+ $attribute);
+ }
+
+ $message[] = pht(
+ 'Attribute "repositories.map" should be a map of repository '.
+ 'specifications.');
+
+ $message = implode("\n\n", $message);
+
+ throw new Exception($message);
+ }
+
+ foreach ($map as $key => $value) {
+ $map[$key] = array_select_keys(
+ $value,
+ array(
+ 'phid',
+ ));
+ }
+
+ return $map;
+ }
+
public function activateResource(
DrydockBlueprint $blueprint,
DrydockResource $resource) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 2:37 PM (19 h, 5 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6923736
Default Alt Text
D21796.diff (1 KB)
Attached To
Mode
D21796: Fail in a more comprehensible way when a WorkingCopy lease omits or mangles "repositories.map"
Attached
Detach File
Event Timeline
Log In to Comment