diff --git a/migrations/20210121201822-settings-rename-platform-config-to-services-config.js b/migrations/20210121201822-settings-rename-platform-config-to-services-config.js new file mode 100644 index 000000000..c6829744d --- /dev/null +++ b/migrations/20210121201822-settings-rename-platform-config-to-services-config.js @@ -0,0 +1,9 @@ +'use strict'; + +exports.up = function(db, callback) { + db.runSql('UPDATE settings SET name=? WHERE name=?', [ 'services_config', 'platform_config' ], callback); +}; + +exports.down = function(db, callback) { + db.runSql('UPDATE settings SET name=? WHERE name=?', [ 'platform_config', 'services_config' ], callback); +}; diff --git a/src/platform.js b/src/platform.js index 3a92a06f8..331aa7262 100644 --- a/src/platform.js +++ b/src/platform.js @@ -76,7 +76,7 @@ function onPlatformReady(infraChanged) { exports._isReady = true; let tasks = [ apps.schedulePendingTasks ]; - if (infraChanged) tasks.push(applyPlatformConfig, pruneInfraImages); + if (infraChanged) tasks.push(applyServicesConfig, pruneInfraImages); async.series(async.reflectAll(tasks), function (error, results) { results.forEach((result, idx) => { @@ -85,8 +85,8 @@ function onPlatformReady(infraChanged) { }); } -function applyPlatformConfig(callback) { - settings.getPlatformConfig(function (error, platformConfig) { +function applyServicesConfig(callback) { + settings.getServicesConfig(function (error, platformConfig) { if (error) return callback(error); services.updateServiceConfig(platformConfig, callback); diff --git a/src/services.js b/src/services.js index cc63a1468..3215b7734 100644 --- a/src/services.js +++ b/src/services.js @@ -369,10 +369,10 @@ function getServicesConfig(id, callback) { const [name, instance ] = id.split(':'); if (!instance) { - settings.getPlatformConfig(function (error, platformConfig) { + settings.getServicesConfig(function (error, servicesConfig) { if (error) return callback(error); - callback(null, SERVICES[name], platformConfig); + callback(null, SERVICES[name], servicesConfig); }); return; @@ -467,7 +467,7 @@ function configureService(id, data, callback) { updateAppServiceConfig(name, instance, servicesConfig, callback); }); } else { - settings.setPlatformConfig(servicesConfig, function (error) { + settings.setServicesConfig(servicesConfig, function (error) { if (error) return callback(error); updateServiceConfig(servicesConfig, NOOP_CALLBACK); // this can take a while diff --git a/src/settings.js b/src/settings.js index ba3692e4c..0dae6b9d2 100644 --- a/src/settings.js +++ b/src/settings.js @@ -23,8 +23,8 @@ exports = module.exports = { setBackupConfig, setBackupCredentials, - getPlatformConfig, - setPlatformConfig, + getServicesConfig, + setServicesConfig, getExternalLdapConfig, setExternalLdapConfig, @@ -83,7 +83,7 @@ exports = module.exports = { // json. if you add an entry here, be sure to fix getAll BACKUP_CONFIG_KEY: 'backup_config', - PLATFORM_CONFIG_KEY: 'platform_config', + SERVICES_CONFIG_KEY: 'services_config', EXTERNAL_LDAP_KEY: 'external_ldap_config', REGISTRY_CONFIG_KEY: 'registry_config', SYSINFO_CONFIG_KEY: 'sysinfo_config', @@ -154,7 +154,7 @@ let gDefaults = (function () { retentionPolicy: { keepWithinSecs: 2 * 24 * 60 * 60 }, // 2 days schedulePattern: '00 00 23 * * *' // every day at 11pm }; - result[exports.PLATFORM_CONFIG_KEY] = {}; + result[exports.SERVICES_CONFIG_KEY] = {}; result[exports.EXTERNAL_LDAP_KEY] = { provider: 'noop', autoCreate: false @@ -434,24 +434,24 @@ function setBackupCredentials(credentials, callback) { }); } -function getPlatformConfig(callback) { +function getServicesConfig(callback) { assert.strictEqual(typeof callback, 'function'); - settingsdb.get(exports.PLATFORM_CONFIG_KEY, function (error, value) { - if (error && error.reason === BoxError.NOT_FOUND) return callback(null, gDefaults[exports.PLATFORM_CONFIG_KEY]); + settingsdb.get(exports.SERVICES_CONFIG_KEY, function (error, value) { + if (error && error.reason === BoxError.NOT_FOUND) return callback(null, gDefaults[exports.SERVICES_CONFIG_KEY]); if (error) return callback(error); callback(null, JSON.parse(value)); }); } -function setPlatformConfig(platformConfig, callback) { +function setServicesConfig(platformConfig, callback) { assert.strictEqual(typeof callback, 'function'); - settingsdb.set(exports.PLATFORM_CONFIG_KEY, JSON.stringify(platformConfig), function (error) { + settingsdb.set(exports.SERVICES_CONFIG_KEY, JSON.stringify(platformConfig), function (error) { if (error) return callback(error); - notifyChange(exports.PLATFORM_CONFIG_KEY, platformConfig); + notifyChange(exports.SERVICES_CONFIG_KEY, platformConfig); callback(null); }); @@ -741,7 +741,7 @@ function getAll(callback) { result[exports.DEMO_KEY] = !!result[exports.DEMO_KEY]; // convert JSON objects - [exports.BACKUP_CONFIG_KEY, exports.DIRECTORY_CONFIG_KEY, exports.PLATFORM_CONFIG_KEY, exports.EXTERNAL_LDAP_KEY, exports.REGISTRY_CONFIG_KEY, exports.SYSINFO_CONFIG_KEY ].forEach(function (key) { + [exports.BACKUP_CONFIG_KEY, exports.DIRECTORY_CONFIG_KEY, exports.SERVICES_CONFIG_KEY, exports.EXTERNAL_LDAP_KEY, exports.REGISTRY_CONFIG_KEY, exports.SYSINFO_CONFIG_KEY ].forEach(function (key) { result[key] = typeof result[key] === 'object' ? result[key] : safe.JSON.parse(result[key]); });