Skip to content

Conversation

thorsten-klein
Copy link
Contributor

@thorsten-klein thorsten-klein commented Oct 15, 2025

This is (another) alternative to PR #849. It is easier to discuss this solution while there is already some implementation existing.

Why?

In a big company there are often shared configs for build system and tooling (e.g., west and its configs).
Those generic configs must be applied first and contain some default or fallback values, if the user does not specify any value in any user config.
Depending on the company and team size, multiple different configs need to be stacked.
Remember, that users must always be able to overwrite values from those generic config files within their config.

Proposed Solution

Multiple config files can be specified in the according environment variable (WEST_CONFIG_SYSTEM, WEST_CONFIG_GLOBAL, WEST_CONFIG_LOCAL) for each config level (separated by ':').
The config files are applied in the same order as they are specified, whereby values from later files override earlier ones.

I personally like configuration through env variables, but I fear you don't.
Nevertheless I have prepared this proposal. Maybe it convinces you.

Note: Maybe this mechanism does not make sense for WEST_CONFIG_LOCAL.
This could also be combined with the approach from #849, so that multiple configs per config level are supported with a dropin config directory each. This would be the ultimative solution.

@thorsten-klein thorsten-klein marked this pull request as draft October 15, 2025 13:42
@marc-hb
Copy link
Collaborator

marc-hb commented Oct 15, 2025

This is (another) alternative to PR #849.

I don't see how this is better than #849 dropins, sorry. It seems to have the same complexity (e.g.: how do you append to an existing value?) but with a less convenient and less standard user interface.

@thorsten-klein
Copy link
Contributor Author

thorsten-klein commented Oct 15, 2025

Perfectly fine for me. I just wanted to show it to you for completeness.
I will close this PR now 👍🏻

@marc-hb
Copy link
Collaborator

marc-hb commented Oct 15, 2025

You could have waited for other opinions! They could still come but it's bit less likely in a closed PR.

@thorsten-klein thorsten-klein force-pushed the west-multiple-configs branch 4 times, most recently from e33851f to 8f92d18 Compare October 16, 2025 14:55
Copy link

codecov bot commented Oct 16, 2025

Codecov Report

❌ Patch coverage is 94.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.48%. Comparing base (a3af732) to head (3c9c122).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/west/configuration.py 92.50% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #867      +/-   ##
==========================================
- Coverage   84.52%   84.48%   -0.04%     
==========================================
  Files          11       11              
  Lines        3366     3396      +30     
==========================================
+ Hits         2845     2869      +24     
- Misses        521      527       +6     
Files with missing lines Coverage Δ
src/west/app/config.py 95.04% <100.00%> (+1.43%) ⬆️
src/west/configuration.py 82.31% <92.50%> (-2.61%) ⬇️

... and 2 files with indirect coverage changes

Copy link
Collaborator

@pdgendt pdgendt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I like the simplicity here. A user that sets the environment variable, to change a config file location, already needs to know what they are doing.

Allowing to pass in multiple files is in line with the ConfigParser's functionality.

multiple config files can be specified in the according environment
variable for each config level (separated by 'os.pathsep', which is ';'
on Windows or ':' otherwise). The config files are applied in the same
order as they are specified, whereby values from later files override
earlier ones.
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.

3 participants