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

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

Closed
thomaspoignant opened this issue May 3, 2024 · 5 comments · Fixed by #1902
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed p3 Longer term priority

Comments

@thomaspoignant
Copy link
Owner

thomaspoignant commented May 3, 2024

Observed behaviour

When running the relayproxy it is possible to override the configuration file using environment variables.
If the configuration to override is inside an array it is not possible to override it.

This is particularly true when dealing with secrets as mentioned in #1822.

With the current implementation of koanf this is not working well, we should consider following what is proposed in this issue knadh/koanf#74.

Expected Behavior

We want to be able to override a property from the key retrievers with an environment variable.

Something like

export RETRIEVERS_0_HEADERS_AUTHORIZATION=Bearer xxx
@thomaspoignant thomaspoignant added bug Something isn't working p3 Longer term priority help wanted Extra attention is needed labels May 3, 2024
@luanxuechao
Copy link
Contributor

Hi @thomaspoignant , I try to fix it, but I've found a bug in local, when I set yaml in the local:

listen: 1031
pollingInterval: 1000
startWithRetrieverError: false
retriever:
  kind: http
  url: https://raw.githubusercontent.com/thomaspoignant/go-feature-flag/main/examples/retriever_file/flags.goff.yaml
retrievers:
   - kind: file
     path: examples/retriever_file/flags.goff.yaml
  - kind: file
    path: examples/retriever_file/flags.goff.yaml

exporter:
  kind: log
enableSwagger: true
authorizedKeys:
  evaluation:
    - apikey1 # owner: userID1
    - apikey2 # owner: userID2
  admin:
    - apikey3

the retrievers of config can't load from the yaml file.

@thomaspoignant
Copy link
Owner Author

thomaspoignant commented May 15, 2024

@luanxuechao from your example I see an indentation issue in your file on the providers.
Can you try this one instead?

listen: 1031
pollingInterval: 1000
startWithRetrieverError: false
retriever:
  kind: http
  url: https://raw.githubusercontent.com/thomaspoignant/go-feature-flag/main/examples/retriever_file/flags.goff.yaml
retrievers:
  - kind: file
    path: examples/retriever_file/flags.goff.yaml
  - kind: file
    path: examples/retriever_file/flags.goff.yaml

exporter:
  kind: log
enableSwagger: true
authorizedKeys:
  evaluation:
    - apikey1 # owner: userID1
    - apikey2 # owner: userID2
  admin:
    - apikey3

Can you double check if this will solve your issue?

@luanxuechao
Copy link
Contributor

luanxuechao commented May 15, 2024

Hi @thomaspoignant, it doesn't work. I run the relayproxy/main.go with goff-proxy.yaml, and debug it. I'm new developer of golang. I also can reproduce it with json config. go version is: go version go1.22.3 darwin/arm64
image

@thomaspoignant
Copy link
Owner Author

thomaspoignant commented May 15, 2024

@luanxuechao I've tried the same file as you and I don't reproduce.
What I have done:

  1. copy/paste the file (the one edited by myself in the previous comment) in the root directory of go-feature-flag.
  2. Start the relay-proxy in IntelliJ (inside cmd/relay-proxy/main.go).
  3. Add a debugger point at this line:
    apiServer := api.New(proxyConf, services, zapLog)
  4. Here is the output I got:
    Screenshot 2024-05-15 at 12 31 58

@thomaspoignant
Copy link
Owner Author

@luanxuechao if you want you can also join the slack channel https://gofeatureflag.org/slack and we can discuss about your issue there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed p3 Longer term priority
Projects
None yet
2 participants