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

feat(config): add multiple file config sources #1907

Merged
merged 16 commits into from
Nov 16, 2023
Merged

Conversation

gurinderu
Copy link
Contributor

@gurinderu gurinderu commented Nov 15, 2023

Description

Allow to pass --config argument multiple times and allow to pass multiple paths in FLUENCE_CONFIG env.

Motivation

Want to have a layered configuration: define based things in one file and override them with another config.

Related Issue(s)

https://linear.app/fluence/issue/NET-594/add-option-to-nox-cli-to-consume-several-configtomls
https://linear.app/fluence/issue/NET-616/remove-unused-options-in-nox-config

Proposed Changes

The initial file for loading is a Config.toml located near the nox binary file but it is not required.
The second priority is all files from FLUENCE_CONFIG env, separated by comma (,)
The last priority is files passed by the --config argument. The last config has the higher priority and overrides provided values from previous configs. All files provided by FLUENCE_CONFIG and --config should exist.

Additional Notes

Also removed unused values in configs.

Checklist

  • The code follows the project's coding conventions and style guidelines.
  • All tests related to the changes have passed successfully.
  • Documentation has been updated to reflect the changes (if applicable).
  • All new and existing unit tests have passed.
  • I have self-reviewed my code and ensured its quality.
  • I have added/updated necessary comments to aid understanding.

Reviewer Checklist

  • Code has been reviewed for quality and adherence to guidelines.
  • Tests have been reviewed and are sufficient to validate the changes.
  • Documentation has been reviewed and is up to date.
  • Any questions or concerns have been addressed.

Copy link

linear bot commented Nov 15, 2023

NET-594 Add option to Nox CLI to consume several Config.tomls

--config should become repeatable, and these configs should be merged according to Layered Config logic

@gurinderu gurinderu marked this pull request as ready for review November 15, 2023 14:13
@gurinderu gurinderu added the e2e Run e2e workflow label Nov 15, 2023
@folex
Copy link
Member

folex commented Nov 15, 2023

What about --config + --configs, where former always has the lowest priority?

I remember @nahsi said it's important cuz Ansible can reorder flags.

@gurinderu
Copy link
Contributor Author

What about --config + --configs, where former always has the lowest priority?

I remember @nahsi said it's important cuz Ansible can reorder flags.

I have discussed these options with @nahsi and it is not the ansible problem. It is a problem with some cases (like jinja2) when software uses a map for args instead of vec. The map doesn't have the order. Also, he showed as an example a consul agent, but it works in the same way (you can pass -config-file multiple times and the last has higher priority and overrides the previous)

nox/src/main.rs Show resolved Hide resolved
gurinderu and others added 2 commits November 16, 2023 21:06
Co-authored-by: folex <0xdxdy@gmail.com>
Co-authored-by: folex <0xdxdy@gmail.com>
@gurinderu gurinderu enabled auto-merge (squash) November 16, 2023 18:43
@gurinderu gurinderu merged commit 8bba3ea into master Nov 16, 2023
14 checks passed
@gurinderu gurinderu deleted the feature/net-594 branch November 16, 2023 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e Run e2e workflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants