mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +01:00
Add bin/harbormaster write-log
to write some arbitrary content into a new Harbormaster log
Summary: Ref T13088. This is currently minimal but the modify-execute development loop on build logs is extremely long without it. Test Plan: Ran `echo hi | ./bin/harbormaster write-log --target 12345`, saw the log show up in the web UI. Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13088 Differential Revision: https://secure.phabricator.com/D19130
This commit is contained in:
parent
7aab7e80af
commit
cd4c4dc2ff
2 changed files with 64 additions and 0 deletions
|
@ -1311,6 +1311,7 @@ phutil_register_library_map(array(
|
|||
'HarbormasterManagementRestartWorkflow' => 'applications/harbormaster/management/HarbormasterManagementRestartWorkflow.php',
|
||||
'HarbormasterManagementUpdateWorkflow' => 'applications/harbormaster/management/HarbormasterManagementUpdateWorkflow.php',
|
||||
'HarbormasterManagementWorkflow' => 'applications/harbormaster/management/HarbormasterManagementWorkflow.php',
|
||||
'HarbormasterManagementWriteLogWorkflow' => 'applications/harbormaster/management/HarbormasterManagementWriteLogWorkflow.php',
|
||||
'HarbormasterMessageType' => 'applications/harbormaster/engine/HarbormasterMessageType.php',
|
||||
'HarbormasterObject' => 'applications/harbormaster/storage/HarbormasterObject.php',
|
||||
'HarbormasterOtherBuildStepGroup' => 'applications/harbormaster/stepgroup/HarbormasterOtherBuildStepGroup.php',
|
||||
|
@ -6614,6 +6615,7 @@ phutil_register_library_map(array(
|
|||
'HarbormasterManagementRestartWorkflow' => 'HarbormasterManagementWorkflow',
|
||||
'HarbormasterManagementUpdateWorkflow' => 'HarbormasterManagementWorkflow',
|
||||
'HarbormasterManagementWorkflow' => 'PhabricatorManagementWorkflow',
|
||||
'HarbormasterManagementWriteLogWorkflow' => 'HarbormasterManagementWorkflow',
|
||||
'HarbormasterMessageType' => 'Phobject',
|
||||
'HarbormasterObject' => 'HarbormasterDAO',
|
||||
'HarbormasterOtherBuildStepGroup' => 'HarbormasterBuildStepGroup',
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
final class HarbormasterManagementWriteLogWorkflow
|
||||
extends HarbormasterManagementWorkflow {
|
||||
|
||||
protected function didConstruct() {
|
||||
$this
|
||||
->setName('write-log')
|
||||
->setExamples('**write-log** --target __id__ [__options__]')
|
||||
->setSynopsis(pht('Write a new Harbormaster build log.'))
|
||||
->setArguments(
|
||||
array(
|
||||
array(
|
||||
'name' => 'target',
|
||||
'param' => 'id',
|
||||
'help' => pht(
|
||||
'Build Target ID to attach the log to.'),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
public function execute(PhutilArgumentParser $args) {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$target_id = $args->getArg('target');
|
||||
if (!$target_id) {
|
||||
throw new PhutilArgumentUsageException(
|
||||
pht('Choose a build target to attach the log to with "--target".'));
|
||||
}
|
||||
|
||||
$target = id(new HarbormasterBuildTargetQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($target_id))
|
||||
->executeOne();
|
||||
if (!$target) {
|
||||
throw new PhutilArgumentUsageException(
|
||||
pht(
|
||||
'Unable to load build target "%s".',
|
||||
$target_id));
|
||||
}
|
||||
|
||||
|
||||
$log = HarbormasterBuildLog::initializeNewBuildLog($target);
|
||||
$log->openBuildLog();
|
||||
|
||||
echo tsprintf(
|
||||
"%s\n",
|
||||
pht('Reading log from stdin...'));
|
||||
|
||||
$content = file_get_contents('php://stdin');
|
||||
$log->append($content);
|
||||
|
||||
$log->closeBuildLog();
|
||||
|
||||
echo tsprintf(
|
||||
"%s\n",
|
||||
pht('Done.'));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue