Skip to content
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

Configuration overhaul: migrate to Figment crate #592

Conversation

josecelano
Copy link
Member

@josecelano josecelano commented May 17, 2024

Configuration overhaul: migrate to Figment crate.

Subtasks

  • Rename TorrustIndex to Settings.
  • Remove more unused code.
  • Move semantic validation to Settings.
  • Add figment crate.
  • Use Figment to load the configuration from the toml file.
  • Remove config crate.
  • Move config env var constants like ENV_VAR_CONFIG from src/bootstrap to src/config (I will do it in a new PR).

In a new PR

Use Figment convention for env vars to override tracker API token and auth secret. After this PR is merged, both options will be available (old and new names). We can remove the old ones after replacing all the old env vars in this repo and the Index GUI.

Rename env vars:

TORRUST_INDEX_CONFIG             -> TORRUST_INDEX_CONFIG_TOML
TORRUST_INDEX_PATH_CONFIG        -> TORRUST_INDEX_CONFIG_TOML_PATH
TORRUST_INDEX_TRACKER_API_TOKEN  -> TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN
TORRUST_INDEX_AUTH_SECRET_KEY    -> TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__SECRET_KEY

@josecelano josecelano self-assigned this May 17, 2024
@josecelano josecelano added this to the v3.0.0 milestone May 17, 2024
@josecelano josecelano added the Code Cleanup / Refactoring Tidying and Making Neat label May 17, 2024
@josecelano josecelano requested a review from da2ce7 May 17, 2024 16:08
@josecelano josecelano linked an issue May 17, 2024 that may be closed by this pull request
@josecelano josecelano force-pushed the 581-configuration-overhaul-migrate-configuration-to-figment branch from c71e4a8 to d97e86f Compare May 17, 2024 16:12
@josecelano josecelano force-pushed the 581-configuration-overhaul-migrate-configuration-to-figment branch from d97e86f to a068103 Compare May 17, 2024 16:17
@josecelano josecelano force-pushed the 581-configuration-overhaul-migrate-configuration-to-figment branch from a068103 to 790e1ec Compare May 17, 2024 16:17
to the type that has the knowledge.
Use Figment to load settings from toml file and allow overriding
settings with env vars.
after introducing figment::Jail for testing. It seems Jail changes the
current dir and that make other tests fails if they use relative path to
load files (in this case fixtures).

A solution like useing the env var CARGO_MANIFEST_DIR does not work with
`cargo next` when building the container. It only worked when you run
the tests with cargo test.
@josecelano josecelano force-pushed the 581-configuration-overhaul-migrate-configuration-to-figment branch from eccfa4b to 757751f Compare May 21, 2024 07:35
@josecelano josecelano marked this pull request as ready for review May 21, 2024 10:15
@josecelano josecelano merged commit f34c998 into torrust:develop May 21, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Cleanup / Refactoring Tidying and Making Neat
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configuration overhaul: migrate configuration to Figment
1 participant