From 38dcff222570d5f21524a95bc514882995ecc0d7 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Mon, 22 Jan 2024 01:23:40 +0100 Subject: [PATCH 1/3] Use h: as short form of host in log lines Before the rename from hosts were called slave which is why s: made sense. Use h: instead. --- packages/lib/src/logging.ts | 2 +- packages/lib/src/logging_utils.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/lib/src/logging.ts b/packages/lib/src/logging.ts index c673f98e..d9ce0c56 100644 --- a/packages/lib/src/logging.ts +++ b/packages/lib/src/logging.ts @@ -73,7 +73,7 @@ export class WebConsoleFormat { transform(info: any, _options: object) { let src = " "; if (info.host_id !== undefined) { - src += `s:${info.host_name} - `; + src += `h:${info.host_name} - `; } if (info.instance_id !== undefined) { src += `i:${info.instance_name}`; diff --git a/packages/lib/src/logging_utils.ts b/packages/lib/src/logging_utils.ts index 6471c3f7..b3b34d35 100644 --- a/packages/lib/src/logging_utils.ts +++ b/packages/lib/src/logging_utils.ts @@ -163,7 +163,7 @@ export class TerminalFormat { src += `i:${info.instance_name} `; } else if (info.host_name) { - src += `s:${info.host_name} `; + src += `h:${info.host_name} `; } if (info.plugin) { src += `${info.plugin}: `; From e3cfc090d37c6bde174df1f837510c7bba7a7c68 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Tue, 23 Jan 2024 16:36:12 +0100 Subject: [PATCH 2/3] Fix string format of Address When host and instance id in Address was reordered in 1e66f11 the toString method Address was updated to account for this. Fix toString showing host addresses as being instance addresses and vice versa. --- packages/lib/src/data/messages_core.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/lib/src/data/messages_core.ts b/packages/lib/src/data/messages_core.ts index 67ea64a5..b4b3f91e 100644 --- a/packages/lib/src/data/messages_core.ts +++ b/packages/lib/src/data/messages_core.ts @@ -87,7 +87,7 @@ export class Address { } toString() { - const typeMap = ["controller", "instance", "host", "control"]; + const typeMap = ["controller", "host", "instance", "control"]; const type = typeMap[this.type] || this.type; if (this.type === Address.broadcast) { return `[Address ${type}:${typeMap[this.id] || this.id}]`; From 499e973db918e8e8cf32efeb46e55671a51d0b20 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Wed, 24 Jan 2024 02:27:14 +0100 Subject: [PATCH 3/3] Fix InstanceConfigSetPropRequest schema Fix the value incorrectly being set as required in the schema and thus preventing props on config field objects of the instance from being removed. --- CHANGELOG.md | 1 + packages/lib/src/config/classes.ts | 2 +- packages/lib/src/data/messages_instance.ts | 2 +- test/integration/clusterio.js | 9 +++++++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0264def0..6ece0937 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - Fixed host hanging if stopped while an instance is in the process of creating a save during startup. - Fixed `instance.auto_start` option. - Fixed host log spammed with errors when plugins broadcast messages to instances with the plugin disabled. +- Fixed properties of object config fields not being possible to remove. ## Version 2.0.0-alpha.14 diff --git a/packages/lib/src/config/classes.ts b/packages/lib/src/config/classes.ts index 3e26b2c8..dae4fc8a 100644 --- a/packages/lib/src/config/classes.ts +++ b/packages/lib/src/config/classes.ts @@ -459,7 +459,7 @@ export class Config< setProp( name: Field, prop: string, - value: unknown, + value?: unknown, location = this.location, ) { let def = this.constructor.fieldDefinitions[name]; diff --git a/packages/lib/src/data/messages_instance.ts b/packages/lib/src/data/messages_instance.ts index ff29d886..f71b2a13 100644 --- a/packages/lib/src/data/messages_instance.ts +++ b/packages/lib/src/data/messages_instance.ts @@ -208,7 +208,7 @@ export class InstanceConfigSetPropRequest { "instanceId": Type.Integer(), "field": Type.String(), "prop": Type.String(), - "value": Type.Unknown(), + "value": Type.Optional(Type.Unknown()), }); static fromJSON(json: Static) { diff --git a/test/integration/clusterio.js b/test/integration/clusterio.js index d34b8a0d..4fe1f626 100644 --- a/test/integration/clusterio.js +++ b/test/integration/clusterio.js @@ -557,6 +557,15 @@ describe("Integration of Clusterio", function() { slowTest(this); await checkInstanceStatus(44, "running"); }); + it("should allow creating and removing props", async function() { + slowTest(this); + await execCtl("instance config set-prop test factorio.settings new_property new-string-value"); + let config = await getControl().send(new lib.InstanceConfigGetRequest(44)); + assert.equal(config["factorio.settings"]["new_property"], "new-string-value"); + await execCtl("instance config set-prop test factorio.settings new_property"); + config = await getControl().send(new lib.InstanceConfigGetRequest(44)); + assert.equal(config["factorio.settings"]["new_property"], undefined); + }); }); describe("user set-admin/whitelisted/banned", function() {