-
Notifications
You must be signed in to change notification settings - Fork 11
feat: add renaming mechanism for EnvVarProvider #75
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: add renaming mechanism for EnvVarProvider #75
Conversation
Summary of ChangesHello @MatteoJoliveau, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces a flexible renaming mechanism for the EnvVarProvider by using a generic Rename trait. The implementation is well-designed, particularly the use of Cow for efficiency and the blanket implementation for closures, which makes the API very ergonomic. My review includes a few suggestions to improve code idiom and test clarity. Overall, this is a great addition.
| evaluation_context: &EvaluationContext, | ||
| ) -> EvaluationResult<ResolutionDetails<bool>> { | ||
| return evaluate_environment_variable(flag_key, evaluation_context); | ||
| return evaluate_environment_variable(&self.rename, flag_key, evaluation_context); |
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.
In Rust, the return keyword is typically omitted for the final expression of a function, as the last expression is implicitly returned. Removing it makes the code more idiomatic and aligns with common Rust style.
| return evaluate_environment_variable(&self.rename, flag_key, evaluation_context); | |
| evaluate_environment_variable(&self.rename, flag_key, evaluation_context) |
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.
While I agree with this suggestion (and can add a commit fixing this if maintainers agree), I have to point out that this was not a change I introduced 😅
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.
Thanks for your contribution! If you are open to continue contributing, would appreciate your support 🙏
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.
@erenatas I can't promise anything, but my company is introducing OpenFeature so you might hear from us again 😄
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.
Nice to meet you! Over CNCF Slack, there is an openfeature-flagd channel. Feel free to join :)
| evaluation_context: &EvaluationContext, | ||
| ) -> EvaluationResult<ResolutionDetails<f64>> { | ||
| return evaluate_environment_variable(flag_key, evaluation_context); | ||
| return evaluate_environment_variable(&self.rename, flag_key, evaluation_context); |
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.
In Rust, the return keyword is typically omitted for the final expression of a function. It's more idiomatic to rely on the implicit return.
| return evaluate_environment_variable(&self.rename, flag_key, evaluation_context); | |
| evaluate_environment_variable(&self.rename, flag_key, evaluation_context) |
| evaluation_context: &EvaluationContext, | ||
| ) -> EvaluationResult<ResolutionDetails<String>> { | ||
| return evaluate_environment_variable(flag_key, evaluation_context); | ||
| return evaluate_environment_variable(&self.rename, flag_key, evaluation_context); |
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.
In Rust, the return keyword is typically omitted for the final expression of a function. It's more idiomatic to rely on the implicit return.
| return evaluate_environment_variable(&self.rename, flag_key, evaluation_context); | |
| evaluate_environment_variable(&self.rename, flag_key, evaluation_context) |
7983981 to
f083099
Compare
|
Hi Matteo, can you rebase your PR? Thanks |
f083099 to
545f2bd
Compare
|
@erenatas done 👍🏻 |
EnvVarProvider now supports injecting a custom renaming strategy, which allows users to customize how environment variables are selected by transforming the requested flag key. Signed-off-by: Matteo Joliveau <matteo@matteojoliveau.com>
545f2bd to
bb08baa
Compare
EnvVarProvider now supports injecting a custom renaming strategy, which allows users to customise how environment variables are selected by transforming the requested flag key.
This PR
Renametrait toEnvVarProvider, which allows users to inject custom strategies for transforming flag keys into the corresponding environment variable name.How to test
Unit tests have been added. I tried to add a case to the Cucumber world, but I'm not familiar with that system, and I had issues injecting a generic
Rinto the World.