1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-03 11:21:01 +01:00

Convert cluster/projects config options to newer modular structure

Summary: Ref T12845. Converts the cluster and project config options to the new stuff; this is mostly just shifting boilerplate around.

Test Plan: Edited, deleted, and mangled these options from the web UI and CLI.

Reviewers: chad, amckinley

Reviewed By: amckinley

Maniphest Tasks: T12845

Differential Revision: https://secure.phabricator.com/D18166
This commit is contained in:
epriestley 2017-06-27 09:50:57 -07:00
parent 6984d239b0
commit b46e2bb4cc
13 changed files with 77 additions and 80 deletions

View file

@ -2331,13 +2331,13 @@ phutil_register_library_map(array(
'PhabricatorChunkedFileStorageEngine' => 'applications/files/engine/PhabricatorChunkedFileStorageEngine.php',
'PhabricatorClassConfigType' => 'applications/config/type/PhabricatorClassConfigType.php',
'PhabricatorClusterConfigOptions' => 'applications/config/option/PhabricatorClusterConfigOptions.php',
'PhabricatorClusterDatabasesConfigOptionType' => 'infrastructure/cluster/config/PhabricatorClusterDatabasesConfigOptionType.php',
'PhabricatorClusterDatabasesConfigType' => 'infrastructure/cluster/config/PhabricatorClusterDatabasesConfigType.php',
'PhabricatorClusterException' => 'infrastructure/cluster/exception/PhabricatorClusterException.php',
'PhabricatorClusterExceptionHandler' => 'infrastructure/cluster/exception/PhabricatorClusterExceptionHandler.php',
'PhabricatorClusterImpossibleWriteException' => 'infrastructure/cluster/exception/PhabricatorClusterImpossibleWriteException.php',
'PhabricatorClusterImproperWriteException' => 'infrastructure/cluster/exception/PhabricatorClusterImproperWriteException.php',
'PhabricatorClusterNoHostForRoleException' => 'infrastructure/cluster/exception/PhabricatorClusterNoHostForRoleException.php',
'PhabricatorClusterSearchConfigOptionType' => 'infrastructure/cluster/config/PhabricatorClusterSearchConfigOptionType.php',
'PhabricatorClusterSearchConfigType' => 'infrastructure/cluster/config/PhabricatorClusterSearchConfigType.php',
'PhabricatorClusterServiceHealthRecord' => 'infrastructure/cluster/PhabricatorClusterServiceHealthRecord.php',
'PhabricatorClusterStrandedException' => 'infrastructure/cluster/exception/PhabricatorClusterStrandedException.php',
'PhabricatorColumnProxyInterface' => 'applications/project/interface/PhabricatorColumnProxyInterface.php',
@ -3199,7 +3199,7 @@ phutil_register_library_map(array(
'PhabricatorNotificationQuery' => 'applications/notification/query/PhabricatorNotificationQuery.php',
'PhabricatorNotificationSearchEngine' => 'applications/notification/query/PhabricatorNotificationSearchEngine.php',
'PhabricatorNotificationServerRef' => 'applications/notification/client/PhabricatorNotificationServerRef.php',
'PhabricatorNotificationServersConfigOptionType' => 'applications/notification/config/PhabricatorNotificationServersConfigOptionType.php',
'PhabricatorNotificationServersConfigType' => 'applications/notification/config/PhabricatorNotificationServersConfigType.php',
'PhabricatorNotificationStatusView' => 'applications/notification/view/PhabricatorNotificationStatusView.php',
'PhabricatorNotificationTestController' => 'applications/notification/controller/PhabricatorNotificationTestController.php',
'PhabricatorNotificationTestFeedStory' => 'applications/notification/feed/PhabricatorNotificationTestFeedStory.php',
@ -3614,7 +3614,7 @@ phutil_register_library_map(array(
'PhabricatorProjectBoardViewController' => 'applications/project/controller/PhabricatorProjectBoardViewController.php',
'PhabricatorProjectCardView' => 'applications/project/view/PhabricatorProjectCardView.php',
'PhabricatorProjectColorTransaction' => 'applications/project/xaction/PhabricatorProjectColorTransaction.php',
'PhabricatorProjectColorsConfigOptionType' => 'applications/project/config/PhabricatorProjectColorsConfigOptionType.php',
'PhabricatorProjectColorsConfigType' => 'applications/project/config/PhabricatorProjectColorsConfigType.php',
'PhabricatorProjectColumn' => 'applications/project/storage/PhabricatorProjectColumn.php',
'PhabricatorProjectColumnDetailController' => 'applications/project/controller/PhabricatorProjectColumnDetailController.php',
'PhabricatorProjectColumnEditController' => 'applications/project/controller/PhabricatorProjectColumnEditController.php',
@ -3652,7 +3652,7 @@ phutil_register_library_map(array(
'PhabricatorProjectHovercardEngineExtension' => 'applications/project/engineextension/PhabricatorProjectHovercardEngineExtension.php',
'PhabricatorProjectIconSet' => 'applications/project/icon/PhabricatorProjectIconSet.php',
'PhabricatorProjectIconTransaction' => 'applications/project/xaction/PhabricatorProjectIconTransaction.php',
'PhabricatorProjectIconsConfigOptionType' => 'applications/project/config/PhabricatorProjectIconsConfigOptionType.php',
'PhabricatorProjectIconsConfigType' => 'applications/project/config/PhabricatorProjectIconsConfigType.php',
'PhabricatorProjectImageTransaction' => 'applications/project/xaction/PhabricatorProjectImageTransaction.php',
'PhabricatorProjectInterface' => 'applications/project/interface/PhabricatorProjectInterface.php',
'PhabricatorProjectListController' => 'applications/project/controller/PhabricatorProjectListController.php',
@ -7581,13 +7581,13 @@ phutil_register_library_map(array(
'PhabricatorChunkedFileStorageEngine' => 'PhabricatorFileStorageEngine',
'PhabricatorClassConfigType' => 'PhabricatorTextConfigType',
'PhabricatorClusterConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorClusterDatabasesConfigOptionType' => 'PhabricatorConfigJSONOptionType',
'PhabricatorClusterDatabasesConfigType' => 'PhabricatorJSONConfigType',
'PhabricatorClusterException' => 'Exception',
'PhabricatorClusterExceptionHandler' => 'PhabricatorRequestExceptionHandler',
'PhabricatorClusterImpossibleWriteException' => 'PhabricatorClusterException',
'PhabricatorClusterImproperWriteException' => 'PhabricatorClusterException',
'PhabricatorClusterNoHostForRoleException' => 'Exception',
'PhabricatorClusterSearchConfigOptionType' => 'PhabricatorConfigJSONOptionType',
'PhabricatorClusterSearchConfigType' => 'PhabricatorJSONConfigType',
'PhabricatorClusterServiceHealthRecord' => 'Phobject',
'PhabricatorClusterStrandedException' => 'PhabricatorClusterException',
'PhabricatorColumnsEditField' => 'PhabricatorPHIDListEditField',
@ -8552,7 +8552,7 @@ phutil_register_library_map(array(
'PhabricatorNotificationQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorNotificationSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorNotificationServerRef' => 'Phobject',
'PhabricatorNotificationServersConfigOptionType' => 'PhabricatorConfigJSONOptionType',
'PhabricatorNotificationServersConfigType' => 'PhabricatorJSONConfigType',
'PhabricatorNotificationStatusView' => 'AphrontTagView',
'PhabricatorNotificationTestController' => 'PhabricatorNotificationController',
'PhabricatorNotificationTestFeedStory' => 'PhabricatorFeedStory',
@ -9065,7 +9065,7 @@ phutil_register_library_map(array(
'PhabricatorProjectBoardViewController' => 'PhabricatorProjectBoardController',
'PhabricatorProjectCardView' => 'AphrontTagView',
'PhabricatorProjectColorTransaction' => 'PhabricatorProjectTransactionType',
'PhabricatorProjectColorsConfigOptionType' => 'PhabricatorConfigJSONOptionType',
'PhabricatorProjectColorsConfigType' => 'PhabricatorJSONConfigType',
'PhabricatorProjectColumn' => array(
'PhabricatorProjectDAO',
'PhabricatorApplicationTransactionInterface',
@ -9116,7 +9116,7 @@ phutil_register_library_map(array(
'PhabricatorProjectHovercardEngineExtension' => 'PhabricatorHovercardEngineExtension',
'PhabricatorProjectIconSet' => 'PhabricatorIconSet',
'PhabricatorProjectIconTransaction' => 'PhabricatorProjectTransactionType',
'PhabricatorProjectIconsConfigOptionType' => 'PhabricatorConfigJSONOptionType',
'PhabricatorProjectIconsConfigType' => 'PhabricatorJSONConfigType',
'PhabricatorProjectImageTransaction' => 'PhabricatorProjectTransactionType',
'PhabricatorProjectListController' => 'PhabricatorProjectController',
'PhabricatorProjectListView' => 'AphrontView',

View file

@ -20,7 +20,7 @@ final class PhabricatorClusterConfigOptions
}
public function getOptions() {
$databases_type = 'custom:PhabricatorClusterDatabasesConfigOptionType';
$databases_type = 'cluster.databases';
$databases_help = $this->deformat(pht(<<<EOTEXT
WARNING: This is a prototype option and the description below is currently pure
fantasy.
@ -38,7 +38,7 @@ EOTEXT
$intro_href = PhabricatorEnv::getDoclink('Clustering Introduction');
$intro_name = pht('Clustering Introduction');
$search_type = 'custom:PhabricatorClusterSearchConfigOptionType';
$search_type = 'cluster.search';
$search_help = $this->deformat(pht(<<<EOTEXT
Define one or more fulltext storage services. Here you can configure which
hosts will handle fulltext search queries and indexing. For help with

View file

@ -20,7 +20,7 @@ final class PhabricatorNotificationConfigOptions
}
public function getOptions() {
$servers_type = 'custom:PhabricatorNotificationServersConfigOptionType';
$servers_type = 'cluster.notifications';
$servers_help = $this->deformat(pht(<<<EOTEXT
Provide a list of notification servers to enable real-time notifications.

View file

@ -29,10 +29,6 @@ abstract class PhabricatorConfigType extends Phobject {
abstract protected function newHTTPParameterType();
public function validateValue(PhabricatorConfigOption $option, $value) {
return array();
}
public function newTransaction(
PhabricatorConfigOption $option,
$value) {

View file

@ -1,19 +1,17 @@
<?php
final class PhabricatorNotificationServersConfigOptionType
extends PhabricatorConfigJSONOptionType {
final class PhabricatorNotificationServersConfigType
extends PhabricatorJSONConfigType {
public function validateOption(PhabricatorConfigOption $option, $value) {
if (!is_array($value)) {
throw new Exception(
pht(
'Notification server configuration is not valid: value must be a '.
'list of servers'));
}
const TYPEKEY = 'cluster.notifications';
public function validateStoredValue(
PhabricatorConfigOption $option,
$value) {
foreach ($value as $index => $spec) {
if (!is_array($spec)) {
throw new Exception(
throw $this->newException(
pht(
'Notification server configuration is not valid: each entry in '.
'the list must be a dictionary describing a service, but '.
@ -38,7 +36,7 @@ final class PhabricatorNotificationServersConfigOptionType
'disabled' => 'optional bool',
));
} catch (Exception $ex) {
throw new Exception(
throw $this->newException(
pht(
'Notification server configuration has an invalid service '.
'specification (at index "%s"): %s.',
@ -64,7 +62,7 @@ final class PhabricatorNotificationServersConfigOptionType
}
break;
default:
throw new Exception(
throw $this->newException(
pht(
'Notification server configuration describes an invalid '.
'host ("%s", at index "%s") with an unrecognized type ("%s"). '.
@ -81,7 +79,7 @@ final class PhabricatorNotificationServersConfigOptionType
case 'https':
break;
default:
throw new Exception(
throw $this->newException(
pht(
'Notification server configuration describes an invalid '.
'host ("%s", at index "%s") with an invalid protocol ("%s"). '.
@ -95,7 +93,7 @@ final class PhabricatorNotificationServersConfigOptionType
$path = idx($spec, 'path');
if ($type == 'admin' && strlen($path)) {
throw new Exception(
throw $this->newException(
pht(
'Notification server configuration describes an invalid host '.
'("%s", at index "%s"). This is an "admin" service but it has a '.
@ -108,7 +106,7 @@ final class PhabricatorNotificationServersConfigOptionType
// mistakes.
$key = "{$host}:{$port}";
if (isset($map[$key])) {
throw new Exception(
throw $this->newException(
pht(
'Notification server configuration is invalid: it describes the '.
'same host and port ("%s") multiple times. Each host and port '.
@ -120,7 +118,7 @@ final class PhabricatorNotificationServersConfigOptionType
if ($value) {
if (!$has_admin) {
throw new Exception(
throw $this->newException(
pht(
'Notification server configuration is invalid: it does not '.
'specify any enabled servers with type "admin". Notifications '.
@ -128,7 +126,7 @@ final class PhabricatorNotificationServersConfigOptionType
}
if (!$has_client) {
throw new Exception(
throw $this->newException(
pht(
'Notification server configuration is invalid: it does not '.
'specify any enabled servers with type "client". Notifications '.

View file

@ -1,10 +0,0 @@
<?php
final class PhabricatorProjectColorsConfigOptionType
extends PhabricatorConfigJSONOptionType {
public function validateOption(PhabricatorConfigOption $option, $value) {
PhabricatorProjectIconSet::validateColorConfiguration($value);
}
}

View file

@ -0,0 +1,14 @@
<?php
final class PhabricatorProjectColorsConfigType
extends PhabricatorJSONConfigType {
const TYPEKEY = 'project.colors';
public function validateStoredValue(
PhabricatorConfigOption $option,
$value) {
PhabricatorProjectIconSet::validateColorConfiguration($value);
}
}

View file

@ -21,7 +21,7 @@ final class PhabricatorProjectConfigOptions
public function getOptions() {
$default_icons = PhabricatorProjectIconSet::getDefaultConfiguration();
$icons_type = 'custom:PhabricatorProjectIconsConfigOptionType';
$icons_type = 'project.icons';
$icons_description = $this->deformat(pht(<<<EOTEXT
Allows you to change and customize the available project icons.
@ -48,7 +48,7 @@ EOTEXT
));
$default_colors = PhabricatorProjectIconSet::getDefaultColorMap();
$colors_type = 'custom:PhabricatorProjectColorsConfigOptionType';
$colors_type = 'project.colors';
$colors_description = $this->deformat(pht(<<<EOTEXT
Allows you to relabel project colors.

View file

@ -1,10 +0,0 @@
<?php
final class PhabricatorProjectIconsConfigOptionType
extends PhabricatorConfigJSONOptionType {
public function validateOption(PhabricatorConfigOption $option, $value) {
PhabricatorProjectIconSet::validateConfiguration($value);
}
}

View file

@ -0,0 +1,14 @@
<?php
final class PhabricatorProjectIconsConfigType
extends PhabricatorJSONConfigType {
const TYPEKEY = 'project.icons';
public function validateStoredValue(
PhabricatorConfigOption $option,
$value) {
PhabricatorProjectIconSet::validateConfiguration($value);
}
}

View file

@ -13,7 +13,7 @@ abstract class PhabricatorSearchManagementWorkflow
$config_value = PhabricatorEnv::getEnvConfig($config_key);
try {
PhabricatorClusterSearchConfigOptionType::validateValue($config_value);
PhabricatorClusterSearchConfigType::validateValue($config_value);
} catch (Exception $ex) {
throw new PhutilArgumentUsageException(
pht(

View file

@ -1,19 +1,17 @@
<?php
final class PhabricatorClusterDatabasesConfigOptionType
extends PhabricatorConfigJSONOptionType {
final class PhabricatorClusterDatabasesConfigType
extends PhabricatorJSONConfigType {
public function validateOption(PhabricatorConfigOption $option, $value) {
if (!is_array($value)) {
throw new Exception(
pht(
'Database cluster configuration is not valid: value must be a '.
'list of database hosts.'));
}
const TYPEKEY = 'cluster.databases';
public function validateStoredValue(
PhabricatorConfigOption $option,
$value) {
foreach ($value as $index => $spec) {
if (!is_array($spec)) {
throw new Exception(
throw $this->newException(
pht(
'Database cluster configuration is not valid: each entry in the '.
'list must be a dictionary describing a database host, but '.
@ -40,7 +38,7 @@ final class PhabricatorClusterDatabasesConfigOptionType
'persistent' => 'optional bool',
));
} catch (Exception $ex) {
throw new Exception(
throw $this->newException(
pht(
'Database cluster configuration has an invalid host '.
'specification (at index "%s"): %s.',
@ -57,7 +55,7 @@ final class PhabricatorClusterDatabasesConfigOptionType
case 'replica':
break;
default:
throw new Exception(
throw $this->newException(
pht(
'Database cluster configuration describes an invalid '.
'host ("%s", at index "%s") with an unrecognized role ("%s"). '.
@ -78,7 +76,7 @@ final class PhabricatorClusterDatabasesConfigOptionType
// mistakes.
$key = "{$host}:{$port}";
if (isset($map[$key])) {
throw new Exception(
throw $this->newException(
pht(
'Database cluster configuration is invalid: it describes the '.
'same host ("%s") multiple times. Each host should appear only '.

View file

@ -1,20 +1,17 @@
<?php
final class PhabricatorClusterSearchConfigOptionType
extends PhabricatorConfigJSONOptionType {
final class PhabricatorClusterSearchConfigType
extends PhabricatorJSONConfigType {
public function validateOption(PhabricatorConfigOption $option, $value) {
const TYPEKEY = 'cluster.search';
public function validateStoredValue(
PhabricatorConfigOption $option,
$value) {
self::validateValue($value);
}
public static function validateValue($value) {
if (!is_array($value)) {
throw new Exception(
pht(
'Search cluster configuration is not valid: value must be a '.
'list of search hosts.'));
}
$engines = PhabricatorSearchService::loadAllFulltextStorageEngines();
foreach ($value as $index => $spec) {