Set config values with environment variables #64

Open
opened 2019-06-10 09:49:25 +00:00 by b3yond · 3 comments
Owner

Author: @b3yond Posted at: 06.11.2018 08:04

Is your feature request related to a problem? Please describe.
The docker container in https://github.com/ticketfrei/docker-ticketfrei/ needs the option to set config values by environment variables. This would diminish the need for one of the shared volumes, and concentrate configuration in one docker-compose file.

It would be nice to keep the config.toml in the architecture though, if someone needs it - but override the values when environment variables are set.

Describe the solution you'd like
config.py should first check if there is a config file. If there is no config file, it should check if environment variables are set. If they are "", the default values from config.toml.example should be used. Else the environment variables should be used for the config values.

They don't need to be updated during runtime.

Describe alternatives you've considered

  1. The status quo is okay, but requires shared volumes in the docker setup, and a non-intuitive setup process for admins. Copying the config.toml.example -> config.toml and THEN editing it is a bit weird, but necessary due to our git workflows... this could be better.
  2. Using only environment variables is not useful too. For some it may not be easily debugabble to have everything in env variables. If you don't use docker, they are harder to document and everything.

Additional context
Problem: If you want to set one of the values to "" by using an environment variable, the value would be overriden by the default value. This should not be a problem with our current config settings though.

Author: @b3yond Posted at: 06.11.2018 08:04 **Is your feature request related to a problem? Please describe.** The docker container in https://github.com/ticketfrei/docker-ticketfrei/ needs the option to set config values by environment variables. This would diminish the need for one of the shared volumes, and concentrate configuration in one docker-compose file. It would be nice to keep the config.toml in the architecture though, if someone needs it - but override the values when environment variables are set. **Describe the solution you'd like** config.py should first check if there is a config file. If there is no config file, it should check if environment variables are set. If they are "", the default values from config.toml.example should be used. Else the environment variables should be used for the config values. They don't need to be updated during runtime. **Describe alternatives you've considered** 1. The status quo is okay, but requires shared volumes in the docker setup, and a non-intuitive setup process for admins. Copying the config.toml.example -> config.toml and THEN editing it is a bit weird, but necessary due to our git workflows... this could be better. 2. Using only environment variables is not useful too. For some it may not be easily debugabble to have everything in env variables. If you don't use docker, they are harder to document and everything. **Additional context** Problem: If you want to set one of the values to "" by using an environment variable, the value would be overriden by the default value. This should not be a problem with our current config settings though.
b3yond added the
enhancement
wait to be tested
labels 2019-06-10 09:49:25 +00:00
Author
Owner

Author: @b3yond Posted at: 07.11.2018 08:00

This branch can be tested with staging.tfrei.links-tech.org, which currently runs the envs branch. to do: think of test cases.

I already tested if the env vars are set in config.py.

One possible case would be whether twitter works if you supply consumer_key & consumer_secret via .env file.

Where is the web/host variable even used inside the container? not sure.

The contact variable is impossible to test because I think the container can't send mail atm.

Author: @b3yond Posted at: 07.11.2018 08:00 This branch can be tested with staging.tfrei.links-tech.org, which currently runs the envs branch. to do: think of test cases. I already tested if the env vars are set in config.py. One possible case would be whether twitter works if you supply consumer_key & consumer_secret via .env file. Where is the web/host variable even used inside the container? not sure. The contact variable is impossible to test because I think the container can't send mail atm.
Author
Owner

Author: @b3yond Posted at: 19.11.2018 23:09

Author: @b3yond Posted at: 19.11.2018 23:09 * [x] twitter works. <3 * [x] host definitely works, too, the callback url for the twitter API could be generated correctly, for example. * [x] contact needs to be tested. dependent on https://github.com/ticketfrei/docker-ticketfrei/issues/3
Author
Owner

Author: @b3yond Posted at: 11.01.2019 21:50

contact seems to work too, but sending mails doesn't work yet.

Author: @b3yond Posted at: 11.01.2019 21:50 contact seems to work too, but sending mails doesn't work yet.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: b3yond/ticketfrei#64
No description provided.