feat: add valueFrom field handling in envVars for FeatureFlagSource and InProcessConfiguration#802
Conversation
Summary of ChangesHello @KyryloKarpenko, 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 flexibility and security of environment variable management within Highlights
Changelog
Activity
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.
Code Review
This pull request adds support for valueFrom in envVars for FeatureFlagSource and InProcessConfiguration resources. This allows sourcing environment variables from secrets and configmaps, which is a great improvement for managing sensitive data. The implementation is correct and includes necessary test and documentation updates. My feedback focuses on improving code conciseness and consistency in the new logic for handling envVars.
| newEnvVar := corev1.EnvVar{ | ||
| Name: fc.decorateEnvVarName(envVar.Name), | ||
| } | ||
|
|
||
| if envVar.Value != "" { | ||
| newEnvVar.Value = envVar.Value | ||
| } else if envVar.ValueFrom != nil { | ||
| newEnvVar.ValueFrom = envVar.ValueFrom | ||
| } | ||
|
|
||
| envs = append(envs, newEnvVar) |
There was a problem hiding this comment.
The logic for handling value and valueFrom is correct, but it can be simplified for better readability and to be more idiomatic. Also, the indentation seems to be using spaces instead of tabs, which is inconsistent with the rest of the file.
This suggested refactoring is more concise and still correctly prioritizes value over valueFrom.
newEnvVar := envVar
newEnvVar.Name = fc.decorateEnvVarName(envVar.Name)
// Per K8s API, Value and ValueFrom are mutually exclusive.
// If Value is set, we must clear ValueFrom.
if newEnvVar.Value != "" {
newEnvVar.ValueFrom = nil
}
envs = append(envs, newEnvVar)| newEnvVar := corev1.EnvVar{ | ||
| Name: common.EnvVarKey(fc.EnvVarPrefix, envVar.Name), | ||
| } | ||
|
|
||
| if envVar.Value != "" { | ||
| newEnvVar.Value = envVar.Value | ||
| } else if envVar.ValueFrom != nil { | ||
| newEnvVar.ValueFrom = envVar.ValueFrom | ||
| } | ||
|
|
||
| envs = append(envs, newEnvVar) |
There was a problem hiding this comment.
The logic for handling value and valueFrom is correct, but it can be simplified for better readability and to be more idiomatic. Also, the indentation seems to be using spaces instead of tabs, which is inconsistent with the rest of the file.
This suggested refactoring is more concise and still correctly prioritizes value over valueFrom.
newEnvVar := envVar
newEnvVar.Name = common.EnvVarKey(fc.EnvVarPrefix, envVar.Name)
// Per K8s API, Value and ValueFrom are mutually exclusive.
// If Value is set, we must clear ValueFrom.
if newEnvVar.Value != "" {
newEnvVar.ValueFrom = nil
}
envs = append(envs, newEnvVar)|
Hi @beeme1mr, could you have a look, please? |
|
Hi @toddbaert could you please have a look? |
Will review. |
…nd InProcessConfiguration Signed-off-by: KyryloKarpenko <karpenkokirillll55@gmail.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #802 +/- ##
===========================================
- Coverage 86.51% 69.42% -17.10%
===========================================
Files 19 31 +12
Lines 1587 2008 +421
===========================================
+ Hits 1373 1394 +21
- Misses 173 561 +388
- Partials 41 53 +12
... and 24 files with indirect coverage changes
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
Hey @KyryloKarpenko . Great addition. Sorry review took a while, we have a lot of contributions lately. I made some whitespaces changes, and moved your docs out of the blob section, because it's applicable generally, not just there. Thanks again! I think codecov is flagging whitespace changes. Ignoring that. |
This PR
Allow to configure
envVarsusingvalueFromfield.Verified that the Flagd sidecar is created with the configured source (secrets or config map).
Related Issues
-
Notes
According to the CRD documentation for FeatureFlagSource and InProcessConfiguration, it is possible to configure the source for the environment variable's value in the
valueFromfield. In reality, theenvVarscould be configured using only thevaluefield.Follow-up Tasks
-
How to test
Works with
end-to-end.yaml