mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 00:13:13 +09:00
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:
1 parent
37bff10382
commit
c3179f0423
2 files changed
+41
-29
No files matched your search
+1
-29
@@ -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() {
|
async function startControl() {
|
||||||
yargs
|
yargs
|
||||||
.scriptName("clusterctl")
|
.scriptName("clusterctl")
|
||||||
@@ -525,7 +497,7 @@ async function startControl() {
|
|||||||
config.finalizeConfigs();
|
config.finalizeConfigs();
|
||||||
|
|
||||||
console.log(`Loading config from ${args.config}`);
|
console.log(`Loading config from ${args.config}`);
|
||||||
let controlConfig = new ControlConfig();
|
let controlConfig = new config.ControlConfig();
|
||||||
try {
|
try {
|
||||||
await controlConfig.load(JSON.parse(await fs.readFile(args.config)));
|
await controlConfig.load(JSON.parse(await fs.readFile(args.config)));
|
||||||
|
|
||||||
|
|||||||
@@ -258,6 +258,43 @@ InstanceConfig.registerGroup(InstanceGroup);
|
|||||||
InstanceConfig.registerGroup(FactorioGroup);
|
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) {
|
function validateGroup(pluginInfo, groupName) {
|
||||||
if (!pluginInfo[groupName] instanceof classes.PluginConfigGroup) {
|
if (!pluginInfo[groupName] instanceof classes.PluginConfigGroup) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@@ -314,6 +351,7 @@ function finalizeConfigs() {
|
|||||||
MasterConfig.finalize();
|
MasterConfig.finalize();
|
||||||
SlaveConfig.finalize();
|
SlaveConfig.finalize();
|
||||||
InstanceConfig.finalize();
|
InstanceConfig.finalize();
|
||||||
|
ControlConfig.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -387,10 +425,12 @@ module.exports = {
|
|||||||
SlaveGroup,
|
SlaveGroup,
|
||||||
InstanceGroup,
|
InstanceGroup,
|
||||||
FactorioGroup,
|
FactorioGroup,
|
||||||
|
ControlGroup,
|
||||||
|
|
||||||
MasterConfig,
|
MasterConfig,
|
||||||
SlaveConfig,
|
SlaveConfig,
|
||||||
InstanceConfig,
|
InstanceConfig,
|
||||||
|
ControlConfig,
|
||||||
|
|
||||||
registerPluginConfigGroups,
|
registerPluginConfigGroups,
|
||||||
finalizeConfigs,
|
finalizeConfigs,
|
||||||
|
|||||||
Reference in new issue
Block a user