Skip to content

Commit b46e2bb

Browse files
author
epriestley
committedJun 27, 2017
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
1 parent 6984d23 commit b46e2bb

13 files changed

+77
-80
lines changed
 

‎src/__phutil_library_map__.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -2331,13 +2331,13 @@
23312331
'PhabricatorChunkedFileStorageEngine' => 'applications/files/engine/PhabricatorChunkedFileStorageEngine.php',
23322332
'PhabricatorClassConfigType' => 'applications/config/type/PhabricatorClassConfigType.php',
23332333
'PhabricatorClusterConfigOptions' => 'applications/config/option/PhabricatorClusterConfigOptions.php',
2334-
'PhabricatorClusterDatabasesConfigOptionType' => 'infrastructure/cluster/config/PhabricatorClusterDatabasesConfigOptionType.php',
2334+
'PhabricatorClusterDatabasesConfigType' => 'infrastructure/cluster/config/PhabricatorClusterDatabasesConfigType.php',
23352335
'PhabricatorClusterException' => 'infrastructure/cluster/exception/PhabricatorClusterException.php',
23362336
'PhabricatorClusterExceptionHandler' => 'infrastructure/cluster/exception/PhabricatorClusterExceptionHandler.php',
23372337
'PhabricatorClusterImpossibleWriteException' => 'infrastructure/cluster/exception/PhabricatorClusterImpossibleWriteException.php',
23382338
'PhabricatorClusterImproperWriteException' => 'infrastructure/cluster/exception/PhabricatorClusterImproperWriteException.php',
23392339
'PhabricatorClusterNoHostForRoleException' => 'infrastructure/cluster/exception/PhabricatorClusterNoHostForRoleException.php',
2340-
'PhabricatorClusterSearchConfigOptionType' => 'infrastructure/cluster/config/PhabricatorClusterSearchConfigOptionType.php',
2340+
'PhabricatorClusterSearchConfigType' => 'infrastructure/cluster/config/PhabricatorClusterSearchConfigType.php',
23412341
'PhabricatorClusterServiceHealthRecord' => 'infrastructure/cluster/PhabricatorClusterServiceHealthRecord.php',
23422342
'PhabricatorClusterStrandedException' => 'infrastructure/cluster/exception/PhabricatorClusterStrandedException.php',
23432343
'PhabricatorColumnProxyInterface' => 'applications/project/interface/PhabricatorColumnProxyInterface.php',
@@ -3199,7 +3199,7 @@
31993199
'PhabricatorNotificationQuery' => 'applications/notification/query/PhabricatorNotificationQuery.php',
32003200
'PhabricatorNotificationSearchEngine' => 'applications/notification/query/PhabricatorNotificationSearchEngine.php',
32013201
'PhabricatorNotificationServerRef' => 'applications/notification/client/PhabricatorNotificationServerRef.php',
3202-
'PhabricatorNotificationServersConfigOptionType' => 'applications/notification/config/PhabricatorNotificationServersConfigOptionType.php',
3202+
'PhabricatorNotificationServersConfigType' => 'applications/notification/config/PhabricatorNotificationServersConfigType.php',
32033203
'PhabricatorNotificationStatusView' => 'applications/notification/view/PhabricatorNotificationStatusView.php',
32043204
'PhabricatorNotificationTestController' => 'applications/notification/controller/PhabricatorNotificationTestController.php',
32053205
'PhabricatorNotificationTestFeedStory' => 'applications/notification/feed/PhabricatorNotificationTestFeedStory.php',
@@ -3614,7 +3614,7 @@
36143614
'PhabricatorProjectBoardViewController' => 'applications/project/controller/PhabricatorProjectBoardViewController.php',
36153615
'PhabricatorProjectCardView' => 'applications/project/view/PhabricatorProjectCardView.php',
36163616
'PhabricatorProjectColorTransaction' => 'applications/project/xaction/PhabricatorProjectColorTransaction.php',
3617-
'PhabricatorProjectColorsConfigOptionType' => 'applications/project/config/PhabricatorProjectColorsConfigOptionType.php',
3617+
'PhabricatorProjectColorsConfigType' => 'applications/project/config/PhabricatorProjectColorsConfigType.php',
36183618
'PhabricatorProjectColumn' => 'applications/project/storage/PhabricatorProjectColumn.php',
36193619
'PhabricatorProjectColumnDetailController' => 'applications/project/controller/PhabricatorProjectColumnDetailController.php',
36203620
'PhabricatorProjectColumnEditController' => 'applications/project/controller/PhabricatorProjectColumnEditController.php',
@@ -3652,7 +3652,7 @@
36523652
'PhabricatorProjectHovercardEngineExtension' => 'applications/project/engineextension/PhabricatorProjectHovercardEngineExtension.php',
36533653
'PhabricatorProjectIconSet' => 'applications/project/icon/PhabricatorProjectIconSet.php',
36543654
'PhabricatorProjectIconTransaction' => 'applications/project/xaction/PhabricatorProjectIconTransaction.php',
3655-
'PhabricatorProjectIconsConfigOptionType' => 'applications/project/config/PhabricatorProjectIconsConfigOptionType.php',
3655+
'PhabricatorProjectIconsConfigType' => 'applications/project/config/PhabricatorProjectIconsConfigType.php',
36563656
'PhabricatorProjectImageTransaction' => 'applications/project/xaction/PhabricatorProjectImageTransaction.php',
36573657
'PhabricatorProjectInterface' => 'applications/project/interface/PhabricatorProjectInterface.php',
36583658
'PhabricatorProjectListController' => 'applications/project/controller/PhabricatorProjectListController.php',
@@ -7581,13 +7581,13 @@
75817581
'PhabricatorChunkedFileStorageEngine' => 'PhabricatorFileStorageEngine',
75827582
'PhabricatorClassConfigType' => 'PhabricatorTextConfigType',
75837583
'PhabricatorClusterConfigOptions' => 'PhabricatorApplicationConfigOptions',
7584-
'PhabricatorClusterDatabasesConfigOptionType' => 'PhabricatorConfigJSONOptionType',
7584+
'PhabricatorClusterDatabasesConfigType' => 'PhabricatorJSONConfigType',
75857585
'PhabricatorClusterException' => 'Exception',
75867586
'PhabricatorClusterExceptionHandler' => 'PhabricatorRequestExceptionHandler',
75877587
'PhabricatorClusterImpossibleWriteException' => 'PhabricatorClusterException',
75887588
'PhabricatorClusterImproperWriteException' => 'PhabricatorClusterException',
75897589
'PhabricatorClusterNoHostForRoleException' => 'Exception',
7590-
'PhabricatorClusterSearchConfigOptionType' => 'PhabricatorConfigJSONOptionType',
7590+
'PhabricatorClusterSearchConfigType' => 'PhabricatorJSONConfigType',
75917591
'PhabricatorClusterServiceHealthRecord' => 'Phobject',
75927592
'PhabricatorClusterStrandedException' => 'PhabricatorClusterException',
75937593
'PhabricatorColumnsEditField' => 'PhabricatorPHIDListEditField',
@@ -8552,7 +8552,7 @@
85528552
'PhabricatorNotificationQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
85538553
'PhabricatorNotificationSearchEngine' => 'PhabricatorApplicationSearchEngine',
85548554
'PhabricatorNotificationServerRef' => 'Phobject',
8555-
'PhabricatorNotificationServersConfigOptionType' => 'PhabricatorConfigJSONOptionType',
8555+
'PhabricatorNotificationServersConfigType' => 'PhabricatorJSONConfigType',
85568556
'PhabricatorNotificationStatusView' => 'AphrontTagView',
85578557
'PhabricatorNotificationTestController' => 'PhabricatorNotificationController',
85588558
'PhabricatorNotificationTestFeedStory' => 'PhabricatorFeedStory',
@@ -9065,7 +9065,7 @@
90659065
'PhabricatorProjectBoardViewController' => 'PhabricatorProjectBoardController',
90669066
'PhabricatorProjectCardView' => 'AphrontTagView',
90679067
'PhabricatorProjectColorTransaction' => 'PhabricatorProjectTransactionType',
9068-
'PhabricatorProjectColorsConfigOptionType' => 'PhabricatorConfigJSONOptionType',
9068+
'PhabricatorProjectColorsConfigType' => 'PhabricatorJSONConfigType',
90699069
'PhabricatorProjectColumn' => array(
90709070
'PhabricatorProjectDAO',
90719071
'PhabricatorApplicationTransactionInterface',
@@ -9116,7 +9116,7 @@
91169116
'PhabricatorProjectHovercardEngineExtension' => 'PhabricatorHovercardEngineExtension',
91179117
'PhabricatorProjectIconSet' => 'PhabricatorIconSet',
91189118
'PhabricatorProjectIconTransaction' => 'PhabricatorProjectTransactionType',
9119-
'PhabricatorProjectIconsConfigOptionType' => 'PhabricatorConfigJSONOptionType',
9119+
'PhabricatorProjectIconsConfigType' => 'PhabricatorJSONConfigType',
91209120
'PhabricatorProjectImageTransaction' => 'PhabricatorProjectTransactionType',
91219121
'PhabricatorProjectListController' => 'PhabricatorProjectController',
91229122
'PhabricatorProjectListView' => 'AphrontView',

‎src/applications/config/option/PhabricatorClusterConfigOptions.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function getGroup() {
2020
}
2121

2222
public function getOptions() {
23-
$databases_type = 'custom:PhabricatorClusterDatabasesConfigOptionType';
23+
$databases_type = 'cluster.databases';
2424
$databases_help = $this->deformat(pht(<<<EOTEXT
2525
WARNING: This is a prototype option and the description below is currently pure
2626
fantasy.
@@ -38,7 +38,7 @@ public function getOptions() {
3838
$intro_href = PhabricatorEnv::getDoclink('Clustering Introduction');
3939
$intro_name = pht('Clustering Introduction');
4040

41-
$search_type = 'custom:PhabricatorClusterSearchConfigOptionType';
41+
$search_type = 'cluster.search';
4242
$search_help = $this->deformat(pht(<<<EOTEXT
4343
Define one or more fulltext storage services. Here you can configure which
4444
hosts will handle fulltext search queries and indexing. For help with

‎src/applications/config/option/PhabricatorNotificationConfigOptions.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function getGroup() {
2020
}
2121

2222
public function getOptions() {
23-
$servers_type = 'custom:PhabricatorNotificationServersConfigOptionType';
23+
$servers_type = 'cluster.notifications';
2424
$servers_help = $this->deformat(pht(<<<EOTEXT
2525
Provide a list of notification servers to enable real-time notifications.
2626

‎src/applications/config/type/PhabricatorConfigType.php

-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ public function readValueFromRequest(
2929

3030
abstract protected function newHTTPParameterType();
3131

32-
public function validateValue(PhabricatorConfigOption $option, $value) {
33-
return array();
34-
}
35-
3632
public function newTransaction(
3733
PhabricatorConfigOption $option,
3834
$value) {

‎src/applications/notification/config/PhabricatorNotificationServersConfigOptionType.php ‎src/applications/notification/config/PhabricatorNotificationServersConfigType.php

+15-17
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
<?php
22

3-
final class PhabricatorNotificationServersConfigOptionType
4-
extends PhabricatorConfigJSONOptionType {
3+
final class PhabricatorNotificationServersConfigType
4+
extends PhabricatorJSONConfigType {
55

6-
public function validateOption(PhabricatorConfigOption $option, $value) {
7-
if (!is_array($value)) {
8-
throw new Exception(
9-
pht(
10-
'Notification server configuration is not valid: value must be a '.
11-
'list of servers'));
12-
}
6+
const TYPEKEY = 'cluster.notifications';
7+
8+
public function validateStoredValue(
9+
PhabricatorConfigOption $option,
10+
$value) {
1311

1412
foreach ($value as $index => $spec) {
1513
if (!is_array($spec)) {
16-
throw new Exception(
14+
throw $this->newException(
1715
pht(
1816
'Notification server configuration is not valid: each entry in '.
1917
'the list must be a dictionary describing a service, but '.
@@ -38,7 +36,7 @@ public function validateOption(PhabricatorConfigOption $option, $value) {
3836
'disabled' => 'optional bool',
3937
));
4038
} catch (Exception $ex) {
41-
throw new Exception(
39+
throw $this->newException(
4240
pht(
4341
'Notification server configuration has an invalid service '.
4442
'specification (at index "%s"): %s.',
@@ -64,7 +62,7 @@ public function validateOption(PhabricatorConfigOption $option, $value) {
6462
}
6563
break;
6664
default:
67-
throw new Exception(
65+
throw $this->newException(
6866
pht(
6967
'Notification server configuration describes an invalid '.
7068
'host ("%s", at index "%s") with an unrecognized type ("%s"). '.
@@ -81,7 +79,7 @@ public function validateOption(PhabricatorConfigOption $option, $value) {
8179
case 'https':
8280
break;
8381
default:
84-
throw new Exception(
82+
throw $this->newException(
8583
pht(
8684
'Notification server configuration describes an invalid '.
8785
'host ("%s", at index "%s") with an invalid protocol ("%s"). '.
@@ -95,7 +93,7 @@ public function validateOption(PhabricatorConfigOption $option, $value) {
9593

9694
$path = idx($spec, 'path');
9795
if ($type == 'admin' && strlen($path)) {
98-
throw new Exception(
96+
throw $this->newException(
9997
pht(
10098
'Notification server configuration describes an invalid host '.
10199
'("%s", at index "%s"). This is an "admin" service but it has a '.
@@ -108,7 +106,7 @@ public function validateOption(PhabricatorConfigOption $option, $value) {
108106
// mistakes.
109107
$key = "{$host}:{$port}";
110108
if (isset($map[$key])) {
111-
throw new Exception(
109+
throw $this->newException(
112110
pht(
113111
'Notification server configuration is invalid: it describes the '.
114112
'same host and port ("%s") multiple times. Each host and port '.
@@ -120,15 +118,15 @@ public function validateOption(PhabricatorConfigOption $option, $value) {
120118

121119
if ($value) {
122120
if (!$has_admin) {
123-
throw new Exception(
121+
throw $this->newException(
124122
pht(
125123
'Notification server configuration is invalid: it does not '.
126124
'specify any enabled servers with type "admin". Notifications '.
127125
'require at least one active "admin" server.'));
128126
}
129127

130128
if (!$has_client) {
131-
throw new Exception(
129+
throw $this->newException(
132130
pht(
133131
'Notification server configuration is invalid: it does not '.
134132
'specify any enabled servers with type "client". Notifications '.

‎src/applications/project/config/PhabricatorProjectColorsConfigOptionType.php

-10
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
final class PhabricatorProjectColorsConfigType
4+
extends PhabricatorJSONConfigType {
5+
6+
const TYPEKEY = 'project.colors';
7+
8+
public function validateStoredValue(
9+
PhabricatorConfigOption $option,
10+
$value) {
11+
PhabricatorProjectIconSet::validateColorConfiguration($value);
12+
}
13+
14+
}

‎src/applications/project/config/PhabricatorProjectConfigOptions.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function getGroup() {
2121

2222
public function getOptions() {
2323
$default_icons = PhabricatorProjectIconSet::getDefaultConfiguration();
24-
$icons_type = 'custom:PhabricatorProjectIconsConfigOptionType';
24+
$icons_type = 'project.icons';
2525

2626
$icons_description = $this->deformat(pht(<<<EOTEXT
2727
Allows you to change and customize the available project icons.
@@ -48,7 +48,7 @@ public function getOptions() {
4848
));
4949

5050
$default_colors = PhabricatorProjectIconSet::getDefaultColorMap();
51-
$colors_type = 'custom:PhabricatorProjectColorsConfigOptionType';
51+
$colors_type = 'project.colors';
5252

5353
$colors_description = $this->deformat(pht(<<<EOTEXT
5454
Allows you to relabel project colors.

‎src/applications/project/config/PhabricatorProjectIconsConfigOptionType.php

-10
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
final class PhabricatorProjectIconsConfigType
4+
extends PhabricatorJSONConfigType {
5+
6+
const TYPEKEY = 'project.icons';
7+
8+
public function validateStoredValue(
9+
PhabricatorConfigOption $option,
10+
$value) {
11+
PhabricatorProjectIconSet::validateConfiguration($value);
12+
}
13+
14+
}

‎src/applications/search/management/PhabricatorSearchManagementWorkflow.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ protected function validateClusterSearchConfig() {
1313
$config_value = PhabricatorEnv::getEnvConfig($config_key);
1414

1515
try {
16-
PhabricatorClusterSearchConfigOptionType::validateValue($config_value);
16+
PhabricatorClusterSearchConfigType::validateValue($config_value);
1717
} catch (Exception $ex) {
1818
throw new PhutilArgumentUsageException(
1919
pht(

‎src/infrastructure/cluster/config/PhabricatorClusterDatabasesConfigOptionType.php ‎src/infrastructure/cluster/config/PhabricatorClusterDatabasesConfigType.php

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
<?php
22

3-
final class PhabricatorClusterDatabasesConfigOptionType
4-
extends PhabricatorConfigJSONOptionType {
3+
final class PhabricatorClusterDatabasesConfigType
4+
extends PhabricatorJSONConfigType {
55

6-
public function validateOption(PhabricatorConfigOption $option, $value) {
7-
if (!is_array($value)) {
8-
throw new Exception(
9-
pht(
10-
'Database cluster configuration is not valid: value must be a '.
11-
'list of database hosts.'));
12-
}
6+
const TYPEKEY = 'cluster.databases';
7+
8+
public function validateStoredValue(
9+
PhabricatorConfigOption $option,
10+
$value) {
1311

1412
foreach ($value as $index => $spec) {
1513
if (!is_array($spec)) {
16-
throw new Exception(
14+
throw $this->newException(
1715
pht(
1816
'Database cluster configuration is not valid: each entry in the '.
1917
'list must be a dictionary describing a database host, but '.
@@ -40,7 +38,7 @@ public function validateOption(PhabricatorConfigOption $option, $value) {
4038
'persistent' => 'optional bool',
4139
));
4240
} catch (Exception $ex) {
43-
throw new Exception(
41+
throw $this->newException(
4442
pht(
4543
'Database cluster configuration has an invalid host '.
4644
'specification (at index "%s"): %s.',
@@ -57,7 +55,7 @@ public function validateOption(PhabricatorConfigOption $option, $value) {
5755
case 'replica':
5856
break;
5957
default:
60-
throw new Exception(
58+
throw $this->newException(
6159
pht(
6260
'Database cluster configuration describes an invalid '.
6361
'host ("%s", at index "%s") with an unrecognized role ("%s"). '.
@@ -78,7 +76,7 @@ public function validateOption(PhabricatorConfigOption $option, $value) {
7876
// mistakes.
7977
$key = "{$host}:{$port}";
8078
if (isset($map[$key])) {
81-
throw new Exception(
79+
throw $this->newException(
8280
pht(
8381
'Database cluster configuration is invalid: it describes the '.
8482
'same host ("%s") multiple times. Each host should appear only '.

‎src/infrastructure/cluster/config/PhabricatorClusterSearchConfigOptionType.php ‎src/infrastructure/cluster/config/PhabricatorClusterSearchConfigType.php

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
<?php
22

3-
final class PhabricatorClusterSearchConfigOptionType
4-
extends PhabricatorConfigJSONOptionType {
3+
final class PhabricatorClusterSearchConfigType
4+
extends PhabricatorJSONConfigType {
55

6-
public function validateOption(PhabricatorConfigOption $option, $value) {
6+
const TYPEKEY = 'cluster.search';
7+
8+
public function validateStoredValue(
9+
PhabricatorConfigOption $option,
10+
$value) {
711
self::validateValue($value);
812
}
913

1014
public static function validateValue($value) {
11-
if (!is_array($value)) {
12-
throw new Exception(
13-
pht(
14-
'Search cluster configuration is not valid: value must be a '.
15-
'list of search hosts.'));
16-
}
17-
1815
$engines = PhabricatorSearchService::loadAllFulltextStorageEngines();
1916

2017
foreach ($value as $index => $spec) {

0 commit comments

Comments
 (0)
Failed to load comments.