refactor into getServiceConfig
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
exports = module.exports = {
|
||||
getServiceConfig,
|
||||
|
||||
listServices,
|
||||
getServiceStatus,
|
||||
getServiceLogs,
|
||||
@@ -345,12 +347,16 @@ async function listServices() {
|
||||
return serviceIds;
|
||||
}
|
||||
|
||||
async function getConfig() {
|
||||
return await settings.getJson(settings.SERVICES_CONFIG_KEY) || {};
|
||||
}
|
||||
|
||||
async function getServiceConfig(id) {
|
||||
assert.strictEqual(typeof id, 'string');
|
||||
|
||||
const [name, instance] = id.split(':');
|
||||
if (!instance) {
|
||||
const servicesConfig = await settings.getJson(settings.SERVICES_CONFIG_KEY) || {};
|
||||
const servicesConfig = await getConfig();
|
||||
return servicesConfig[name] || {};
|
||||
}
|
||||
|
||||
@@ -423,7 +429,7 @@ async function configureService(id, data, auditSource) {
|
||||
|
||||
await apps.update(instance, { servicesConfig });
|
||||
} else if (SERVICES[name]) {
|
||||
const servicesConfig = await settings.getJson(settings.SERVICES_CONFIG_KEY) || {};
|
||||
const servicesConfig = await getConfig();
|
||||
needsRebuild = servicesConfig[name]?.recoveryMode != data.recoveryMode; // intentional != since 'recoveryMode' may or may not be there
|
||||
servicesConfig[name] = data;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user