Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F87938
D7695.diff
All Users
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D7695.diff
View Options
diff --git a/src/applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php b/src/applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php
--- a/src/applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php
+++ b/src/applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php
@@ -37,6 +37,21 @@
DrydockResource $resource,
DrydockLease $lease) {
+ // Because preallocated resources are manually created, we should verify
+ // we have all the information we need.
+ PhutilTypeSpec::checkMap(
+ $resource->getAttributesForTypeSpec(
+ array('platform', 'host', 'port', 'user', 'path')),
+ array(
+ 'platform' => 'string',
+ 'host' => 'string',
+ 'port' => 'string', // Value is a string from the command line
+ 'user' => 'string',
+ 'path' => 'string',
+ ));
+ $v_platform = $resource->getAttribute('platform');
+ $v_path = $resource->getAttribute('path');
+
// Similar to DrydockLocalHostBlueprint, we create a folder
// on the remote host that the lease can use.
@@ -46,18 +61,18 @@
// the platform we're currently running on, not the platform we are
// remoting to.
$separator = '/';
- if ($lease->getAttribute('platform') === 'windows') {
+ if ($v_platform === 'windows') {
$separator = '\\';
}
// Clean up the directory path a little.
- $base_path = rtrim($resource->getAttribute('path'), '/');
+ $base_path = rtrim($v_path, '/');
$base_path = rtrim($base_path, '\\');
$full_path = $base_path.$separator.$lease_id;
$cmd = $lease->getInterface('command');
- if ($lease->getAttribute('platform') !== 'windows') {
+ if ($v_platform !== 'windows') {
$cmd->execx('mkdir %s', $full_path);
} else {
// Windows is terrible. The mkdir command doesn't even support putting
diff --git a/src/applications/drydock/storage/DrydockResource.php b/src/applications/drydock/storage/DrydockResource.php
--- a/src/applications/drydock/storage/DrydockResource.php
+++ b/src/applications/drydock/storage/DrydockResource.php
@@ -35,6 +35,10 @@
return idx($this->attributes, $key, $default);
}
+ public function getAttributesForTypeSpec(array $attribute_names) {
+ return array_select_keys($this->attributes, $attribute_names);
+ }
+
public function setAttribute($key, $value) {
$this->attributes[$key] = $value;
return $this;
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/5f/wr/hnzz3jf33vkzc6xx
Default Alt Text
D7695.diff (2 KB)
Attached To
Mode
D7695: Validate resource attributes for preallocated hosts before executing leases
Attached
Detach File
Event Timeline
Log In to Comment