aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
authorJelle Besseling <jelle@pingiun.com>2021-10-12 13:33:44 +0200
committerGitHub <noreply@github.com>2021-10-12 13:33:44 +0200
commit8d8a037e3fe9b1d2ccbc4169ce59b13000b59cb0 (patch)
tree755ba56bc3acbd82ec195974545581c1e49aae5e /server/initializers
parentbadacdbb4a3e4a1aae4d324abc496be8e261b2ef (diff)
downloadPeerTube-8d8a037e3fe9b1d2ccbc4169ce59b13000b59cb0.tar.gz
PeerTube-8d8a037e3fe9b1d2ccbc4169ce59b13000b59cb0.tar.zst
PeerTube-8d8a037e3fe9b1d2ccbc4169ce59b13000b59cb0.zip
Allow configuration to be static/readonly (#4315)
* Allow configuration to be static/readonly * Make all components disableable * Improve disabled component styling * Rename edits allowed field in configuration * Fix CI
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/config.ts31
1 files changed, 23 insertions, 8 deletions
diff --git a/server/initializers/config.ts b/server/initializers/config.ts
index be9fc61f0..b2a8e9e19 100644
--- a/server/initializers/config.ts
+++ b/server/initializers/config.ts
@@ -195,6 +195,13 @@ const CONFIG = {
195 URL: config.get<string>('peertube.check_latest_version.url') 195 URL: config.get<string>('peertube.check_latest_version.url')
196 } 196 }
197 }, 197 },
198 WEBADMIN: {
199 CONFIGURATION: {
200 EDITS: {
201 ALLOWED: config.get<boolean>('webadmin.configuration.edit.allowed')
202 }
203 }
204 },
198 ADMIN: { 205 ADMIN: {
199 get EMAIL () { return config.get<string>('admin.email') } 206 get EMAIL () { return config.get<string>('admin.email') }
200 }, 207 },
@@ -411,14 +418,22 @@ export {
411// --------------------------------------------------------------------------- 418// ---------------------------------------------------------------------------
412 419
413function getLocalConfigFilePath () { 420function getLocalConfigFilePath () {
414 const configSources = config.util.getConfigSources() 421 const localConfigDir = getLocalConfigDir()
415 if (configSources.length === 0) throw new Error('Invalid config source.')
416 422
417 let filename = 'local' 423 let filename = 'local'
418 if (process.env.NODE_ENV) filename += `-${process.env.NODE_ENV}` 424 if (process.env.NODE_ENV) filename += `-${process.env.NODE_ENV}`
419 if (process.env.NODE_APP_INSTANCE) filename += `-${process.env.NODE_APP_INSTANCE}` 425 if (process.env.NODE_APP_INSTANCE) filename += `-${process.env.NODE_APP_INSTANCE}`
420 426
421 return join(dirname(configSources[0].name), filename + '.json') 427 return join(localConfigDir, filename + '.json')
428}
429
430function getLocalConfigDir () {
431 if (process.env.PEERTUBE_LOCAL_CONFIG) return process.env.PEERTUBE_LOCAL_CONFIG
432
433 const configSources = config.util.getConfigSources()
434 if (configSources.length === 0) throw new Error('Invalid config source.')
435
436 return dirname(configSources[0].name)
422} 437}
423 438
424function buildVideosRedundancy (objs: any[]): VideosRedundancyStrategy[] { 439function buildVideosRedundancy (objs: any[]): VideosRedundancyStrategy[] {
@@ -437,19 +452,19 @@ function buildVideosRedundancy (objs: any[]): VideosRedundancyStrategy[] {
437 452
438export function reloadConfig () { 453export function reloadConfig () {
439 454
440 function getConfigDirectory () { 455 function getConfigDirectories () {
441 if (process.env.NODE_CONFIG_DIR) { 456 if (process.env.NODE_CONFIG_DIR) {
442 return process.env.NODE_CONFIG_DIR 457 return process.env.NODE_CONFIG_DIR.split(":")
443 } 458 }
444 459
445 return join(root(), 'config') 460 return [ join(root(), 'config') ]
446 } 461 }
447 462
448 function purge () { 463 function purge () {
449 const directory = getConfigDirectory() 464 const directories = getConfigDirectories()
450 465
451 for (const fileName in require.cache) { 466 for (const fileName in require.cache) {
452 if (fileName.includes(directory) === false) { 467 if (directories.some((dir) => fileName.includes(dir)) === false) {
453 continue 468 continue
454 } 469 }
455 470