-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat(config): toml inheritance support #11284
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
Conversation
@mattsse would make sense to give users the ability to decide on the inheritance strategy? imo it could be useful to pick between if u agree with the suggestion, i thought we could expose these 2 inheritance modes: "extend-arrays" or "replace-arrays" wdyt? 🤔 |
should we automatically resolve conflicts or just error and let dev change setup? |
personally i think that resolving is fine, as imo makes sense for maybe building on top of what i proposed to @mattsse above, we could have a strategy config (i.e. "no-collisions"), which prevents extending and which panics if there are key collisions? could be the default and if they see that it panics, they can change the merge strategy |
I don't have a strong opinion but would also like to avoid any misunderstanding, what do other think? @mattsse @DaniPopes @yash-atreya pls chime in
|
went ahead and updated the PR with support for 3 strategies as mentioned above: /// Strategy for extending configuration from a base file.
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum ExtendStrategy {
/// Uses `admerge` figment strategy.
/// Arrays are concatenated (base elements + local elements).
/// Other values are replaced (local values override base values).
ExtendArrays,
/// Uses `merge` figment strategy.
/// Arrays are replaced entirely (local arrays replace base arrays).
/// Other values are replaced (local values override base values).
ReplaceArrays,
/// Throws an error if any of the keys in the inherited toml file are also in `foundry.toml`.
NoCollision,
} i currently have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lil nit
Co-authored-by: onbjerg <onbjerg@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense
Motivation
refs:
config
): introduce [extends] field to extend with other Foundry config files (foundry.toml
) #10594Solution
This PR introduces a new field
extends
which allows forfoundry.toml
to inherit a base config from another toml file. Effectively extending its base config for the active profile.Relevant considerations:
BASE (inherited toml file) < LOCAL (foundry.toml) < ENV
foundry.toml
foundry.toml
has configuredextends
+ the inherited file has some config for the selected profile