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

fix(relay-proxy): Allow overide of array configuration by environment variables #1902

Merged
merged 4 commits into from
May 28, 2024

Conversation

luanxuechao
Copy link
Contributor

@luanxuechao luanxuechao commented May 21, 2024

Description

Closes issue(s)

Resolve 1841

Checklist

  • I have tested this code
  • I have added unit test to cover this code
  • I have updated the documentation (README.md and /website/docs)
  • I have followed the contributing guide

Copy link

netlify bot commented May 21, 2024

Deploy Preview for go-feature-flag-doc-preview canceled.

Name Link
🔨 Latest commit 0f52b54
🔍 Latest deploy log https://app.netlify.com/sites/go-feature-flag-doc-preview/deploys/66559736485a280008887d3e

Copy link

codecov bot commented May 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.99%. Comparing base (7992d2c) to head (0f52b54).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1902      +/-   ##
==========================================
+ Coverage   86.81%   86.99%   +0.18%     
==========================================
  Files          96       96              
  Lines        3450     3498      +48     
==========================================
+ Hits         2995     3043      +48     
  Misses        350      350              
  Partials      105      105              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@luanxuechao luanxuechao changed the title Fix:Load array env fix:Load array env May 21, 2024
@luanxuechao luanxuechao force-pushed the luanx/issue-1841 branch 2 times, most recently from 3dfd84a to 769d6c6 Compare May 22, 2024 08:34
@luanxuechao luanxuechao changed the title fix:Load array env fix: Load array env May 22, 2024
@luanxuechao luanxuechao force-pushed the luanx/issue-1841 branch 2 times, most recently from b1d1ef5 to 11dd493 Compare May 22, 2024 08:55
@thomaspoignant thomaspoignant changed the title fix: Load array env fix(relay-proxy): Allow overide of array configuration by environment variables May 24, 2024
Copy link
Owner

@thomaspoignant thomaspoignant left a comment

Choose a reason for hiding this comment

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

Hey @luanxuechao thanks a lot for this pull request and this looks super promising.

I've made some small comments, but the main thing I see is that we cannot add a new entry to the array.

PS: I have changed the title of the PR to make it more explicit.

cmd/relayproxy/config/config.go Outdated Show resolved Hide resolved
cmd/relayproxy/config/config.go Outdated Show resolved Hide resolved
Copy link
Owner

@thomaspoignant thomaspoignant left a comment

Choose a reason for hiding this comment

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

This version is now accepting env variables outside of the range BUT it does not take into consideration multiple variables in the same object.

Something like

RETRIEVERS_1_KIND=github
RETRIEVERS_1_REPOSITORYSLUG=thomaspoignant/go-feature-flag
RETRIEVERS_1_BRANCH=main
RETRIEVERS_1_FILEPATH=testdata/flag-config.yaml

With the actual version of the code, it will only take the last env variable.

When we move the location of the configMap initialization it will work.
I'll suggest that you double-check and that it works, and it is worth adding a test to validate it.

cmd/relayproxy/config/config.go Outdated Show resolved Hide resolved
@@ -91,10 +92,15 @@ func New(flagSet *pflag.FlagSet, log *zap.Logger, version string) (*Config, erro
log.Error("error loading file", zap.Error(errBindFile))
}
}

configMap := k.Raw()
Copy link
Owner

Choose a reason for hiding this comment

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

If we keep this outside of the function we are not able to pass multiple environment variables.

If we have something like

RETRIEVERS_1_KIND=github
RETRIEVERS_1_REPOSITORYSLUG=thomaspoignant/go-feature-flag
RETRIEVERS_1_BRANCH=main
RETRIEVERS_1_FILEPATH=testdata/flag-config.yaml

Only the last environment variable will be taken into consideration.

(check proposal bellow to make it work)

Suggested change
configMap := k.Raw()

cmd/relayproxy/config/config.go Show resolved Hide resolved
Copy link
Owner

@thomaspoignant thomaspoignant left a comment

Choose a reason for hiding this comment

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

I think we had a misunderstanding on my previous comment.
I hope what I said is clarifying a bit why I think it is not working as expected.

Copy link

sonarcloud bot commented May 28, 2024

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Owner

@thomaspoignant thomaspoignant left a comment

Choose a reason for hiding this comment

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

Thanks @luanxuechao 🚀
It will be part of the next GO Feature Flag release.

@thomaspoignant thomaspoignant merged commit 73851d0 into thomaspoignant:main May 28, 2024
22 checks passed
thomaspoignant pushed a commit that referenced this pull request Sep 5, 2024
… variables (#1902)

* fix: Load array env

* Fix comment issue

* Fix comment issue

* Fix comment issue
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.

(bug) [relay-proxy] Override configuration via env variables in retrievers does not work
2 participants