Move ControlConfig to lib/config/definitions.js

Move the definition of the control config to lib/config so that the
master code can use it.
This commit is contained in:
Hornwitser committed 2020-06-15 00:13:25 +02:00
1 parent 37bff10382
commit c3179f0423
2 files changed
+41 -29

No files matched your search

+1 -29
View File
@@ -470,34 +470,6 @@ async function findCredentials(controlConfig) {
}
class ControlGroup extends config.ConfigGroup {}
ControlGroup.groupName = "control";
ControlGroup.define({
name: "master_url",
description: "URL to connect to the master server at",
type: "string",
optional: true,
});
ControlGroup.define({
name: "master_token",
description: "Token to authenticate to master server with.",
type: "string",
optional: true,
});
ControlGroup.define({
name: "reconnect_delay",
title: "Reconnect Delay",
description: "Maximum delay to wait before attempting to reconnect WebSocket",
type: "number",
initial_value: 2,
});
ControlGroup.finalize();
class ControlConfig extends config.Config { }
ControlConfig.registerGroup(ControlGroup);
ControlConfig.finalize();
async function startControl() {
yargs
.scriptName("clusterctl")
@@ -525,7 +497,7 @@ async function startControl() {
config.finalizeConfigs();
console.log(`Loading config from ${args.config}`);
let controlConfig = new ControlConfig();
let controlConfig = new config.ControlConfig();
try {
await controlConfig.load(JSON.parse(await fs.readFile(args.config)));
+40
View File
@@ -258,6 +258,43 @@ InstanceConfig.registerGroup(InstanceGroup);
InstanceConfig.registerGroup(FactorioGroup);
/**
* Control config group for {@link module:lib/config.ControlConfig}
* @extends module:lib/config.ConfigGroup
* @memberof module:lib/config
*/
class ControlGroup extends classes.ConfigGroup {}
ControlGroup.groupName = "control";
ControlGroup.define({
name: "master_url",
description: "URL to connect to the master server at",
type: "string",
optional: true,
});
ControlGroup.define({
name: "master_token",
description: "Token to authenticate to master server with.",
type: "string",
optional: true,
});
ControlGroup.define({
name: "reconnect_delay",
title: "Reconnect Delay",
description: "Maximum delay to wait before attempting to reconnect WebSocket",
type: "number",
initial_value: 2,
});
ControlGroup.finalize();
/**
* Control config class
* @extends module:lib/config.Config
* @memberof module:lib/config
*/
class ControlConfig extends classes.Config { }
ControlConfig.registerGroup(ControlGroup);
function validateGroup(pluginInfo, groupName) {
if (!pluginInfo[groupName] instanceof classes.PluginConfigGroup) {
throw new Error(
@@ -314,6 +351,7 @@ function finalizeConfigs() {
MasterConfig.finalize();
SlaveConfig.finalize();
InstanceConfig.finalize();
ControlConfig.finalize();
}
/**
@@ -387,10 +425,12 @@ module.exports = {
SlaveGroup,
InstanceGroup,
FactorioGroup,
ControlGroup,
MasterConfig,
SlaveConfig,
InstanceConfig,
ControlConfig,
registerPluginConfigGroups,
finalizeConfigs,