-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setting config options from cli may break config #740
Comments
When setting config keys, the program doesn't know whether the key-to-be-modified exists on the Config struct. (Perhaps, with reflection, it is possible to find the field). To allow callers to write non-existent keys, the program would... Before: 1) converts the in-memory *Config to a map 2) sets the key on the map, and 3) writes this map to disk. 4) Then, it converts this map back into an in-memory struct. This commit swaps 3 and 4 so the map can be validated against the struct before being written to disk. This prevents the bug identified in #740.
When setting config keys, the program doesn't know whether the key-to-be-modified exists on the Config struct. (Perhaps, with reflection, it is possible to find the field). To allow callers to write non-existent keys, the program would... Before: 1) converts the in-memory *Config to a map 2) sets the key on the map, and 3) writes this map to disk. 4) Then, it converts this map back into an in-memory struct. This commit swaps 3 and 4 so the map can be validated against the struct before being written to disk. This prevents the bug identified in #740.
When setting config keys, the program doesn't know whether the key-to-be-modified exists on the Config struct. (Perhaps, with reflection, it is possible to find the field). To allow callers to write non-existent keys, the program would... Before: 1) converts the in-memory *Config to a map 2) sets the key on the map, and 3) writes this map to disk. 4) Then, it converts this map back into an in-memory struct. This commit swaps 3 and 4 so the map can be validated against the struct before being written to disk. This prevents the bug identified in #740.
One part of this problem is that the config is written to disk before it is validated against the |
@rht thanks for picking this up. I've since implemented the not sure, what do you think is most intuitive? |
Depends on how the config is used. I will check how postfix, vault, etc nail this, and why. |
From the test result, for intuitiveness sake I'd say why not assume the value is json by default and then put escaped quote around numbers when you need them to be string (e.g. the value of Version.CheckPeriod? Why this is string I have no idea). |
@jbenet This is fixed. |
@rht, that's right, thanks! |
setting the repo's
Log.MaxSizeMB
from the cli breaks the config:the config got a string:
changing it to an int fixes it. BUT:
objects retrieving values from the config should try to parse them from the string.
The text was updated successfully, but these errors were encountered: