mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 00:32:42 +01:00
In "bin/drydock lease", take a JSON "--attributes" so we can accept complex values
Summary: Depends on D19750. See T13210. The `bin/drydock lease` command makes it easier to request ad-hoc leases, but currently takes lease attributes in the form `--attributes x=y,a=b`. This was okay for all leases at the time, but doesn't really work for modern WorkingCopy resources since they take a `repositories.map` which has a dictionary as a value. You can't specify that with `repositories.map=...`. Instead, point `--attributes` at a JSON file or use `--attributes -` to read from stdin. Test Plan: Used `--attributes` with a file and stdin to allocate working copy leases with repositories. Reviewers: amckinley Reviewed By: amckinley Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Differential Revision: https://secure.phabricator.com/D19751
This commit is contained in:
parent
6deb09efcd
commit
1f6869a765
1 changed files with 19 additions and 8 deletions
|
@ -21,8 +21,10 @@ final class DrydockManagementLeaseWorkflow
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'name' => 'attributes',
|
'name' => 'attributes',
|
||||||
'param' => 'name=value,...',
|
'param' => 'file',
|
||||||
'help' => pht('Resource specification.'),
|
'help' => pht(
|
||||||
|
'JSON file with lease attributes. Use "-" to read attributes '.
|
||||||
|
'from stdin.'),
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -49,11 +51,20 @@ final class DrydockManagementLeaseWorkflow
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$attributes = $args->getArg('attributes');
|
$attributes_file = $args->getArg('attributes');
|
||||||
if ($attributes) {
|
if (strlen($attributes_file)) {
|
||||||
$options = new PhutilSimpleOptions();
|
if ($attributes_file == '-') {
|
||||||
$options->setCaseSensitive(true);
|
echo tsprintf(
|
||||||
$attributes = $options->parse($attributes);
|
"%s\n",
|
||||||
|
'Reading JSON attributes from stdin...');
|
||||||
|
$data = file_get_contents('php://stdin');
|
||||||
|
} else {
|
||||||
|
$data = Filesystem::readFile($attributes_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
$attributes = phutil_json_decode($data);
|
||||||
|
} else {
|
||||||
|
$attributes = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$lease = id(new DrydockLease())
|
$lease = id(new DrydockLease())
|
||||||
|
|
Loading…
Reference in a new issue