Skip to content

Pass static settings during load time, allowing being overriden at runtime

Leandro Santiago requested to merge feature/518_static_settings into future/release-2.0

Ref #518 (closed)

To test it, export the environment variable LIGHTMETER_DEFAULT_SETTINGS as following:

export LIGHTMETER_DEFAULT_SETTINGS='{"global": {"localIP": "22.33.44.55", "appLanguage": "pt_BR", "publicURL": "http://example.com/lightmeter/"}, "messenger_slack": {"bearerToken": "AAAABBBBCCCFAKEVALUE", "channel": "some_channel"}, "messenger_email": {"enabled": true, "sender": "user@example.com", "recipients": "alice@example.com, bob@example.com", "serverName": "mail.demo.lightmeter.io", "serverPort": "587", "securityType": "STARTTLS", "authMethod": "password", "username": "user@example.com", "password": "super_secret"}}'

And then start controlcenter with a fresh workspace, go to the settings page. You'll see the above specified fields already filled, as following:

image

If you change those settings in the UI (or save them), they'll be written in the database, and the default ones won't be used anymore.

Important note: this change uses a forked version of the mergo library, used to merge data structures. Those changes are not on mainstream, but you can check the related pull requests at:

Edited by Leandro Santiago

Merge request reports