rename platform config to services config

This commit is contained in:
Girish Ramakrishnan
2021-01-21 12:18:11 -08:00
parent cd1b46848e
commit 0edb673dc6
4 changed files with 26 additions and 17 deletions
@@ -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);
};
+3 -3
View File
@@ -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);
+3 -3
View File
@@ -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
+11 -11
View File
@@ -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]);
});