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

Rework the configuration infrastructure #795

Merged
merged 3 commits into from
May 24, 2024
Merged

Conversation

ctron
Copy link
Collaborator

@ctron ctron commented May 22, 2024

This PR reworks the configuration infrastructure inside of trunk.

The main topics are:

  • Split up stored configuration model (toml) and CLI model (clap)
  • Have the CLI override part of the configuration model
  • Allow re-using clap's env feature instead of envy, as the env-var overrides aligns more with CLI arguments rather then with the stored configuration
  • Support alternate configuration formats
  • Warn about future deprecation in the configuration: there are a few cases where either the configuration outgrew itself, or there had been inconsistencies because of the unified model for config-file/cli-args. Trunk warns about that and suggests migrations.

What's missing:

  • loading from Cargo.toml: that is prepared, but not implemented yet
  • have all tests work: most of them work, some of them don't compile yet
  • Ensure that all example configurations still work
  • find a better way to internally migrate deprecated fields: right now that happens inside each sub-command, I think that's the wrong place.

@simbleau simbleau self-requested a review May 22, 2024 13:50
@simbleau
Copy link
Member

Ping me when it's in a test-able state and I'd love to give this a try!

@ctron ctron force-pushed the feature/cfg_1 branch 5 times, most recently from 0511eb4 to d087c0e Compare May 24, 2024 07:15
@ctron
Copy link
Collaborator Author

ctron commented May 24, 2024

@simbleau I guess now there's something for you to take a look at :) … Loading from Cargo.toml is implemented. There are no additional features yet (like profiles and stuff). But, it's a start. I also added an example cargo-manifest to show how it works.

This refactors most parts of the configuration system. Splitting it
up into a command line argument model, a persistent config file model,
and the runtime model.

The command line arguments (including env-vars) will override the
persisted (or default) config model.

It also adds the ability to parse YAML, JSON, and cargo metadata
in addition to the TOML variant.

This prepares the configuration for future enhancements, like build
profiles, ...
@ctron ctron marked this pull request as ready for review May 24, 2024 15:07
@ctron ctron merged commit 142233a into trunk-rs:main May 24, 2024
51 checks passed
@ctron ctron deleted the feature/cfg_1 branch May 24, 2024 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants