Improve the way Sponge configuration files are loaded/saved#1957
Conversation
lucko
commented
Jun 26, 2018
- World and dimension configurations are now merged with their "parent" config on load
- Each value within a config file is not written to the file if the setting is also present in the parent config with the same value
- The 'config-enabled' property is no longer needed, values from world/dimension configs will always override.
24352b1 to
231e92f
Compare
|
this is gonna break everything for existing configs on API7 as config-enabled is not taken into account during migration, nor if config-enabled even did anything for that config you gonna end up with hundreds of global settings being overwritten for no reason with things in the world/dim configs that were never active to begin with |
I don't like this if it's going to remove entries from the world/dim confs. I think that if something is specified in a world config by a user, it should stay that way. If you set an option to A in the global conf and B in the world conf, fine. You might later then change the global conf to B, that does not mean that the world conf entry should be removed. You might temporarily change an entry in the global conf to test something, only to change it back 30 minutes later. By adding an entry to the world files, you are making an explict choice, we should not be removing that explict choice. I agree with not adding to the file, but we should not remove from the file. |
Yep you're right, I had already thought of this and will account for it in the migration.
I can't think of a way to implement this so we can have both. The reason for stripping values out of the config is that it means existing configurations, saved by the old system, will be cleaned up. Perhaps we could make it a one-time thing though? |
The problem is then we don't know which options should have been explicitly kept. It's easy if we have a Maybe add a There is no ideal solution, I agree, but I think we need to err on the side of caution when removing anything. |
not even, some configs are used even when the config is disabled |
|
Well, that’s that then! |
Edit: Ignore me. |
|
After further discussion on this issue. Here is what should happen
|
231e92f to
4ae2421
Compare
|
I've implemented the latest set of proposed changes. |
|
I have to ask that this please be introduced on either a major version change, or at minimum a minor version change. e.g. 7.1 or 7.2. The docs will need to be versioned in order to migrate cleanly. |
|
@ryantheleach the format doesn't change, and this doesn't affect api at all just looked over the docs at https://docs.spongepowered.org/stable/en/server/getting-started/configuration/sponge-conf.html heck that page is already outdated because newer configs were added recently |
I feel like I need to clear something up with versioning here so that anyone else wondering the same thing can see what the thought processes are. Note that config is an server implementation detail. We only version the API with semver, not the server software. It makes no sense to tie the two together. A release of API 7.1 means a release of the API, not the implementation that goes with it. It's a contract for the developer, not the server owner, and configuration is nothing to do with the developer. Given that we've never versioned our implementation other than with a build number and API revision that it targets (we're always talking about SF 3002 or SV APIX-Y) - our server software (not our API) runs on a continuous delievery track. Each "minor" version should really be seen as each recommended build. Indeed, we need this so that the API can function as intended. It won't change the config layout - this is a safe change. We've made other impl changes that have caused behaviour differences in "stable" (read, stable API targetting) builds before and this will continue. |
|
One thing I've been saying we need to do: Version our config files. Configurate supports versioning, we have a "version" of I'm not keen on bumping minor versions, but what we can do is bump "bug fix" in semver, in the sense that we'd be at something like 7.1.9 at the moment (somewhere in the realm of 8 previous recommended builds?) Then we can further differentiate the versioning scheme between SF and SV as the "recommended changes" would be differentiable for developers and documenters. |
| } | ||
|
|
||
| private void populateInstance() throws ObjectMappingException { | ||
| this.configMapper.populate(this.data.getNode(this.modId)); |
There was a problem hiding this comment.
This needs to set mappedInstance or getConfig will cause NPE.
4ae2421 to
a569f21
Compare
|
okay i pulled last commit and tried it on some existing config i have seems to not work as intended, lots of duplication and it even seems to pull a lot of stuff from the global.conf to all subconfigs branch I build my test jar with is here https://github.com/phit/SpongeCommon/commits/phit/test-config |
* World and dimension configurations are now merged with their "parent" config on load * Each value within a config file is not written to the file if the setting is also present in the parent config with the same value * The 'config-enabled' property is no longer needed, values from world/dimension configs will always override.
a569f21 to
ec2614a
Compare
|
@phit Can you try testing again with the latest chances. blood and I worked through the remaining issues last night (hopefully) :) |
|
will do in a bit, would be nice if you wouldn't squash and force push until its ready to merge, makes it really hard to follow what was changed/fixed |
|
Err sure, I won't do that from now on :) |
|
okay, just a few minor issues by the looks of it, but it works as expected, haven't tested the configs actually being applied, just looked at the files before and after https://phit.link/s/configstuff3.zip my only minor complaint is that stuff like module config, or stuff like not sure if that can be easily fixed with this PR though, otherwise this looks good to me! |
|
@phit Can you test overriding some settings to make sure they work as expected? So put a setting in a world config then try one in dimension. Thanks! |
|
will do when i wake up in a few hours |
|
worked as expected, tested with entity activation range and even auto-populate was fine |
* World and dimension configurations are now merged with their "parent" config on load * Each value within a config file is not written to the file if the setting is also present in the parent config with the same value * The 'config-enabled' property is no longer needed, values from world/dimension configs will always override.