mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Add HarbormasterHookController as an entry point for all Harbormaster hooks
Summary: This makes the set of hooks easily extensible, as a first step toward integrating more 3rd party CI in phorge. Test Plan: Send requests to `/harbormaster/hook/circleci/` and `/harbormaster/hook/buildkite/` and check they run the proper handler. Reviewers: O1 Blessed Committers, Matthew Reviewed By: O1 Blessed Committers, Matthew Subscribers: Matthew, speck, tobiaswiese Maniphest Tasks: T15018 Differential Revision: https://we.phorge.it/D25005
This commit is contained in:
parent
2258ba8535
commit
e7740c8669
8 changed files with 67 additions and 18 deletions
|
@ -1478,13 +1478,13 @@ phutil_register_library_map(array(
|
||||||
'HarbormasterBuildableTransactionEditor' => 'applications/harbormaster/editor/HarbormasterBuildableTransactionEditor.php',
|
'HarbormasterBuildableTransactionEditor' => 'applications/harbormaster/editor/HarbormasterBuildableTransactionEditor.php',
|
||||||
'HarbormasterBuildableTransactionQuery' => 'applications/harbormaster/query/HarbormasterBuildableTransactionQuery.php',
|
'HarbormasterBuildableTransactionQuery' => 'applications/harbormaster/query/HarbormasterBuildableTransactionQuery.php',
|
||||||
'HarbormasterBuildableViewController' => 'applications/harbormaster/controller/HarbormasterBuildableViewController.php',
|
'HarbormasterBuildableViewController' => 'applications/harbormaster/controller/HarbormasterBuildableViewController.php',
|
||||||
'HarbormasterBuildkiteBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterBuildkiteBuildStepImplementation.php',
|
'HarbormasterBuildkiteBuildStepImplementation' => 'applications/harbormaster/integration/buildkite/HarbormasterBuildkiteBuildStepImplementation.php',
|
||||||
'HarbormasterBuildkiteBuildableInterface' => 'applications/harbormaster/interface/HarbormasterBuildkiteBuildableInterface.php',
|
'HarbormasterBuildkiteBuildableInterface' => 'applications/harbormaster/interface/HarbormasterBuildkiteBuildableInterface.php',
|
||||||
'HarbormasterBuildkiteHookController' => 'applications/harbormaster/controller/HarbormasterBuildkiteHookController.php',
|
'HarbormasterBuildkiteHookHandler' => 'applications/harbormaster/integration/buildkite/HarbormasterBuildkiteHookHandler.php',
|
||||||
'HarbormasterBuiltinBuildStepGroup' => 'applications/harbormaster/stepgroup/HarbormasterBuiltinBuildStepGroup.php',
|
'HarbormasterBuiltinBuildStepGroup' => 'applications/harbormaster/stepgroup/HarbormasterBuiltinBuildStepGroup.php',
|
||||||
'HarbormasterCircleCIBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterCircleCIBuildStepImplementation.php',
|
'HarbormasterCircleCIBuildStepImplementation' => 'applications/harbormaster/integration/circleci/HarbormasterCircleCIBuildStepImplementation.php',
|
||||||
'HarbormasterCircleCIBuildableInterface' => 'applications/harbormaster/interface/HarbormasterCircleCIBuildableInterface.php',
|
'HarbormasterCircleCIBuildableInterface' => 'applications/harbormaster/interface/HarbormasterCircleCIBuildableInterface.php',
|
||||||
'HarbormasterCircleCIHookController' => 'applications/harbormaster/controller/HarbormasterCircleCIHookController.php',
|
'HarbormasterCircleCIHookHandler' => 'applications/harbormaster/integration/circleci/HarbormasterCircleCIHookHandler.php',
|
||||||
'HarbormasterConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterConduitAPIMethod.php',
|
'HarbormasterConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterConduitAPIMethod.php',
|
||||||
'HarbormasterControlBuildStepGroup' => 'applications/harbormaster/stepgroup/HarbormasterControlBuildStepGroup.php',
|
'HarbormasterControlBuildStepGroup' => 'applications/harbormaster/stepgroup/HarbormasterControlBuildStepGroup.php',
|
||||||
'HarbormasterController' => 'applications/harbormaster/controller/HarbormasterController.php',
|
'HarbormasterController' => 'applications/harbormaster/controller/HarbormasterController.php',
|
||||||
|
@ -1498,6 +1498,8 @@ phutil_register_library_map(array(
|
||||||
'HarbormasterExternalBuildStepGroup' => 'applications/harbormaster/stepgroup/HarbormasterExternalBuildStepGroup.php',
|
'HarbormasterExternalBuildStepGroup' => 'applications/harbormaster/stepgroup/HarbormasterExternalBuildStepGroup.php',
|
||||||
'HarbormasterFileArtifact' => 'applications/harbormaster/artifact/HarbormasterFileArtifact.php',
|
'HarbormasterFileArtifact' => 'applications/harbormaster/artifact/HarbormasterFileArtifact.php',
|
||||||
'HarbormasterHTTPRequestBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterHTTPRequestBuildStepImplementation.php',
|
'HarbormasterHTTPRequestBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterHTTPRequestBuildStepImplementation.php',
|
||||||
|
'HarbormasterHookController' => 'applications/harbormaster/controller/HarbormasterHookController.php',
|
||||||
|
'HarbormasterHookHandler' => 'applications/harbormaster/integration/HarbormasterHookHandler.php',
|
||||||
'HarbormasterHostArtifact' => 'applications/harbormaster/artifact/HarbormasterHostArtifact.php',
|
'HarbormasterHostArtifact' => 'applications/harbormaster/artifact/HarbormasterHostArtifact.php',
|
||||||
'HarbormasterLeaseWorkingCopyBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php',
|
'HarbormasterLeaseWorkingCopyBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php',
|
||||||
'HarbormasterLintMessagesController' => 'applications/harbormaster/controller/HarbormasterLintMessagesController.php',
|
'HarbormasterLintMessagesController' => 'applications/harbormaster/controller/HarbormasterLintMessagesController.php',
|
||||||
|
@ -7727,10 +7729,10 @@ phutil_register_library_map(array(
|
||||||
'HarbormasterBuildableTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
'HarbormasterBuildableTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
||||||
'HarbormasterBuildableViewController' => 'HarbormasterController',
|
'HarbormasterBuildableViewController' => 'HarbormasterController',
|
||||||
'HarbormasterBuildkiteBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
|
'HarbormasterBuildkiteBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
|
||||||
'HarbormasterBuildkiteHookController' => 'HarbormasterController',
|
'HarbormasterBuildkiteHookHandler' => 'HarbormasterHookHandler',
|
||||||
'HarbormasterBuiltinBuildStepGroup' => 'HarbormasterBuildStepGroup',
|
'HarbormasterBuiltinBuildStepGroup' => 'HarbormasterBuildStepGroup',
|
||||||
'HarbormasterCircleCIBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
|
'HarbormasterCircleCIBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
|
||||||
'HarbormasterCircleCIHookController' => 'HarbormasterController',
|
'HarbormasterCircleCIHookHandler' => 'HarbormasterHookHandler',
|
||||||
'HarbormasterConduitAPIMethod' => 'ConduitAPIMethod',
|
'HarbormasterConduitAPIMethod' => 'ConduitAPIMethod',
|
||||||
'HarbormasterControlBuildStepGroup' => 'HarbormasterBuildStepGroup',
|
'HarbormasterControlBuildStepGroup' => 'HarbormasterBuildStepGroup',
|
||||||
'HarbormasterController' => 'PhabricatorController',
|
'HarbormasterController' => 'PhabricatorController',
|
||||||
|
@ -7744,6 +7746,8 @@ phutil_register_library_map(array(
|
||||||
'HarbormasterExternalBuildStepGroup' => 'HarbormasterBuildStepGroup',
|
'HarbormasterExternalBuildStepGroup' => 'HarbormasterBuildStepGroup',
|
||||||
'HarbormasterFileArtifact' => 'HarbormasterArtifact',
|
'HarbormasterFileArtifact' => 'HarbormasterArtifact',
|
||||||
'HarbormasterHTTPRequestBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
|
'HarbormasterHTTPRequestBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
|
||||||
|
'HarbormasterHookController' => 'HarbormasterController',
|
||||||
|
'HarbormasterHookHandler' => 'Phobject',
|
||||||
'HarbormasterHostArtifact' => 'HarbormasterDrydockLeaseArtifact',
|
'HarbormasterHostArtifact' => 'HarbormasterDrydockLeaseArtifact',
|
||||||
'HarbormasterLeaseWorkingCopyBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
|
'HarbormasterLeaseWorkingCopyBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
|
||||||
'HarbormasterLintMessagesController' => 'HarbormasterController',
|
'HarbormasterLintMessagesController' => 'HarbormasterController',
|
||||||
|
|
|
@ -94,10 +94,7 @@ final class PhabricatorHarbormasterApplication extends PhabricatorApplication {
|
||||||
'lint/' => array(
|
'lint/' => array(
|
||||||
'(?P<id>\d+)/' => 'HarbormasterLintMessagesController',
|
'(?P<id>\d+)/' => 'HarbormasterLintMessagesController',
|
||||||
),
|
),
|
||||||
'hook/' => array(
|
'hook/(?P<handler>[^/]+)/' => 'HarbormasterHookController',
|
||||||
'circleci/' => 'HarbormasterCircleCIHookController',
|
|
||||||
'buildkite/' => 'HarbormasterBuildkiteHookController',
|
|
||||||
),
|
|
||||||
'log/' => array(
|
'log/' => array(
|
||||||
'view/(?P<id>\d+)/(?:\$(?P<lines>\d+(?:-\d+)?))?'
|
'view/(?P<id>\d+)/(?:\$(?P<lines>\d+(?:-\d+)?))?'
|
||||||
=> 'HarbormasterBuildLogViewController',
|
=> 'HarbormasterBuildLogViewController',
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class HarbormasterHookController
|
||||||
|
extends HarbormasterController {
|
||||||
|
|
||||||
|
public function shouldRequireLogin() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handleRequest(AphrontRequest $request) {
|
||||||
|
$name = $request->getURIData('handler');
|
||||||
|
$handler = HarbormasterHookHandler::getHandler($name);
|
||||||
|
|
||||||
|
if (!$handler) {
|
||||||
|
throw new Exception(pht('No handler found for %s', $name));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $handler->handleRequest($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
abstract class HarbormasterHookHandler
|
||||||
|
extends Phobject {
|
||||||
|
|
||||||
|
public static function getHandlers() {
|
||||||
|
return id(new PhutilClassMapQuery())
|
||||||
|
->setAncestorClass(__CLASS__)
|
||||||
|
->setUniqueMethod('getName')
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getHandler($handler) {
|
||||||
|
$base = idx(self::getHandlers(), $handler);
|
||||||
|
|
||||||
|
if ($base) {
|
||||||
|
return (clone $base);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract public function getName();
|
||||||
|
|
||||||
|
abstract public function handleRequest(AphrontRequest $request);
|
||||||
|
|
||||||
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class HarbormasterBuildkiteHookController
|
final class HarbormasterBuildkiteHookHandler
|
||||||
extends HarbormasterController {
|
extends HarbormasterHookHandler {
|
||||||
|
|
||||||
public function shouldRequireLogin() {
|
public function getName() {
|
||||||
return false;
|
return 'buildkite';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -1,10 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class HarbormasterCircleCIHookController
|
final class HarbormasterCircleCIHookHandler
|
||||||
extends HarbormasterController {
|
extends HarbormasterHookHandler {
|
||||||
|
|
||||||
public function shouldRequireLogin() {
|
public function getName() {
|
||||||
return false;
|
return 'circleci';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
Loading…
Reference in a new issue