Improve configuration handling #2

Closed
opened 2021-08-13 14:51:05 +00:00 by adrien · 2 comments
Owner

At the moment, Diplonat reads its configuration variables only from the environment:

  • DIPLONAT_PRIVATE_IP
  • DIPLONAT_REFRESH_TIME
  • DIPLONAT_EXPIRATION_TIME
  • DIPLONAT_CONSUL_NODE_NAME
  • DIPLONAT_CONSUL_URL

I am planning on adding ACME capability to Diplonat. This will add many more configuration options. Using environment variables will become impractical.

I want Diplonat to read its configuration variables from a file (most simple INI-style format, at the moment).
Also, since we are talking about only a few variables, I plan on using only one configuration file at the moment.

The configuration file will allow to eschew environment variables for Diplonat's configuration, but will not obsolete them. As common practice: if both a configuration file and an environment variable provide for the same information, the environment variable superseedes the configuration file's information.

Any comments on the configuration file format?

At the moment, Diplonat reads its configuration variables only from the environment: * DIPLONAT_PRIVATE_IP * DIPLONAT_REFRESH_TIME * DIPLONAT_EXPIRATION_TIME * DIPLONAT_CONSUL_NODE_NAME * DIPLONAT_CONSUL_URL I am planning on adding ACME capability to Diplonat. This will add many more configuration options. Using environment variables will become impractical. I want Diplonat to read its configuration variables from a file (most simple INI-style format, at the moment). Also, since we are talking about only a few variables, I plan on using only one configuration file at the moment. The configuration file will allow to eschew environment variables for Diplonat's configuration, but will not obsolete them. As common practice: if both a configuration file and an environment variable provide for the same information, the environment variable superseedes the configuration file's information. Any comments on the configuration file format?
adrien added the
enhancement
label 2021-08-13 14:52:10 +00:00
Author
Owner

I don't have the experience of the Heroku people that wrote 12factor.net . However, they say one should use the environment instead of writing config files in some language, stored somewhere arbitrary. So I'll stick to the current situation that uses environment variables instead of proposing an anti-feature, and just parse the environment using the crate Envy (as suggested in environment.rs).

Docs:

The trunk crate does a good job with its configuration: a Toml config file is superseeded by the environment variables. See the doc and the code.

I don't have the experience of the Heroku people that wrote 12factor.net . However, they say one should use the environment instead of writing config files in some language, stored somewhere arbitrary. So I'll stick to the current situation that uses environment variables instead of proposing an anti-feature, and just parse the environment using the crate [Envy](https://lib.rs/crates/envy) (as suggested in environment.rs). Docs: * https://www.12factor.net/config * https://blog.doismellburning.co.uk/twelve-factor-config-misunderstandings-and-advice/ The `trunk` crate does a good job with its configuration: a Toml config file is superseeded by the environment variables. See [the doc](https://trunkrs.dev/configuration/) and [the code](https://github.com/thedodd/trunk/blob/7eeaf9e3f67e43d4c17e147da32f9f8ec0254f25/src/config/models.rs).
adrien changed title from Read Diplonat's configuration variables from a configuration file to Improve configuration handling 2021-08-16 09:43:42 +00:00
Author
Owner

Resolved by PR#5!

Resolved by [PR#5](https://git.deuxfleurs.fr/Deuxfleurs/diplonat/pulls/5)!
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
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: Deuxfleurs/diplonat#2
No description provided.