feat: add valueFrom field handling in envVars for FeatureFlagSource and InProcessConfiguration#802
feat: add valueFrom field handling in envVars for FeatureFlagSource and InProcessConfiguration#802KyryloKarpenko wants to merge 1 commit intoopen-feature:mainfrom
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)…nd InProcessConfiguration Signed-off-by: KyryloKarpenko <karpenkokirillll55@gmail.com>
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