Page MenuHomePhabricator

Validate resource attributes for preallocated hosts before executing leases
ClosedPublic

Authored by hach-que on Dec 4 2013, 5:49 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, May 10, 2:59 AM
Unknown Object (File)
Fri, May 9, 7:31 PM
Unknown Object (File)
Thu, May 1, 10:03 AM
Unknown Object (File)
Mon, Apr 28, 3:28 AM
Unknown Object (File)
Sun, Apr 27, 11:05 AM
Unknown Object (File)
Sat, Apr 26, 8:47 PM
Unknown Object (File)
Thu, Apr 24, 8:38 AM
Unknown Object (File)
Thu, Apr 24, 8:38 AM

Details

Summary

This prevents issues when the user hasn't provided the appropriate attributes for a preallocated host.

Test Plan

Attempted to lease against a resource with omitted attributes, got an exception thrown before any SSH commands occurred.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Hmm, this might be a little cleaner and more powerful?

PhutilTypeSpec::checkMap(
  $this->getAttributes('platform', 'host', 'port', 'user', 'path'),
  array(
    'platform' => 'required string',
    'host' => 'required string',
    'port' => 'required int',
    'user' => 'required string',
    'path' => 'required string',
  ));

Then write getAttributes() as:

return array_select_keys($this->attributes, $attribute_names);
hach-que updated this revision to Unknown Object (????).Dec 4 2013, 9:08 PM

Update validation according to feedback