mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 13:22:42 +01:00
Add an extensible "SiteSource" for configuration
Summary: Fixes T2792. This adds a pluggable configuration layer between all the stuff on disk (local/file) and the runtime configurable stuff (database). An install can subclass this source and: - For Phacility, query a remote service (like Almanac) to retrieve hostname-based configuration, allowing one install to serve multiple instances. - Maybe for Phacility, query a remote service (like Phlux) to retrieve sitevar-like configuration (e.g., put everything in readonly mode to deal with a maintenance issue?). Not sure if we'll do this or not. We might just nuke Phlux since Almanac is sort-of-a-superset of it for our purposes. - For third parties, query some other remote service if that makes config management easier. In particular, it would theoretically let you put locked config in Zookeeper or whatever else you want. Test Plan: Added a fake source and saw it inject configuration. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T2792 Differential Revision: https://secure.phabricator.com/D10787
This commit is contained in:
parent
2b495f1f03
commit
6a5369b173
3 changed files with 28 additions and 0 deletions
|
@ -1455,6 +1455,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorConfigSchemaQuery' => 'applications/config/schema/PhabricatorConfigSchemaQuery.php',
|
'PhabricatorConfigSchemaQuery' => 'applications/config/schema/PhabricatorConfigSchemaQuery.php',
|
||||||
'PhabricatorConfigSchemaSpec' => 'applications/config/schema/PhabricatorConfigSchemaSpec.php',
|
'PhabricatorConfigSchemaSpec' => 'applications/config/schema/PhabricatorConfigSchemaSpec.php',
|
||||||
'PhabricatorConfigServerSchema' => 'applications/config/schema/PhabricatorConfigServerSchema.php',
|
'PhabricatorConfigServerSchema' => 'applications/config/schema/PhabricatorConfigServerSchema.php',
|
||||||
|
'PhabricatorConfigSiteSource' => 'infrastructure/env/PhabricatorConfigSiteSource.php',
|
||||||
'PhabricatorConfigSource' => 'infrastructure/env/PhabricatorConfigSource.php',
|
'PhabricatorConfigSource' => 'infrastructure/env/PhabricatorConfigSource.php',
|
||||||
'PhabricatorConfigStackSource' => 'infrastructure/env/PhabricatorConfigStackSource.php',
|
'PhabricatorConfigStackSource' => 'infrastructure/env/PhabricatorConfigStackSource.php',
|
||||||
'PhabricatorConfigStorageSchema' => 'applications/config/schema/PhabricatorConfigStorageSchema.php',
|
'PhabricatorConfigStorageSchema' => 'applications/config/schema/PhabricatorConfigStorageSchema.php',
|
||||||
|
@ -4534,6 +4535,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorConfigSchemaQuery' => 'Phobject',
|
'PhabricatorConfigSchemaQuery' => 'Phobject',
|
||||||
'PhabricatorConfigSchemaSpec' => 'Phobject',
|
'PhabricatorConfigSchemaSpec' => 'Phobject',
|
||||||
'PhabricatorConfigServerSchema' => 'PhabricatorConfigStorageSchema',
|
'PhabricatorConfigServerSchema' => 'PhabricatorConfigStorageSchema',
|
||||||
|
'PhabricatorConfigSiteSource' => 'PhabricatorConfigProxySource',
|
||||||
'PhabricatorConfigStackSource' => 'PhabricatorConfigSource',
|
'PhabricatorConfigStackSource' => 'PhabricatorConfigSource',
|
||||||
'PhabricatorConfigStorageSchema' => 'Phobject',
|
'PhabricatorConfigStorageSchema' => 'Phobject',
|
||||||
'PhabricatorConfigTableSchema' => 'PhabricatorConfigStorageSchema',
|
'PhabricatorConfigTableSchema' => 'PhabricatorConfigStorageSchema',
|
||||||
|
|
17
src/infrastructure/env/PhabricatorConfigSiteSource.php
vendored
Normal file
17
src/infrastructure/env/PhabricatorConfigSiteSource.php
vendored
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional configuration source which loads between local sources and the
|
||||||
|
* database source.
|
||||||
|
*
|
||||||
|
* Subclasses of this source can read external configuration sources (like a
|
||||||
|
* remote server).
|
||||||
|
*/
|
||||||
|
abstract class PhabricatorConfigSiteSource
|
||||||
|
extends PhabricatorConfigProxySource {
|
||||||
|
|
||||||
|
public function getPriority() {
|
||||||
|
return 1000.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
9
src/infrastructure/env/PhabricatorEnv.php
vendored
9
src/infrastructure/env/PhabricatorEnv.php
vendored
|
@ -153,6 +153,15 @@ final class PhabricatorEnv {
|
||||||
// pull in all options from non-phabricator libraries now they are loaded.
|
// pull in all options from non-phabricator libraries now they are loaded.
|
||||||
$default_source->loadExternalOptions();
|
$default_source->loadExternalOptions();
|
||||||
|
|
||||||
|
// If this install has site config sources, load them now.
|
||||||
|
$site_sources = id(new PhutilSymbolLoader())
|
||||||
|
->setAncestorClass('PhabricatorConfigSiteSource')
|
||||||
|
->loadObjects();
|
||||||
|
$site_sources = msort($site_sources, 'getPriority');
|
||||||
|
foreach ($site_sources as $site_source) {
|
||||||
|
$stack->pushSource($site_source);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$stack->pushSource(
|
$stack->pushSource(
|
||||||
id(new PhabricatorConfigDatabaseSource('default'))
|
id(new PhabricatorConfigDatabaseSource('default'))
|
||||||
|
|
Loading…
Reference in a new issue