go-feature-flag
go-feature-flag copied to clipboard
(bug) [relay-proxy] Override configuration via env variables in `retrievers` does not work
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 https://github.com/knadh/koanf/issues/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
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.
@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?
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
@luanxuechao I've tried the same file as you and I don't reproduce. What I have done:
- copy/paste the file (the one edited by myself in the previous comment) in the root directory of go-feature-flag.
- Start the relay-proxy in IntelliJ (inside
cmd/relay-proxy/main.go
). - Add a debugger point at this line: https://github.com/thomaspoignant/go-feature-flag/blob/c982515036ac93cf99312341fb3b7f2ef438e41e/cmd/relayproxy/main.go#L96
- Here is the output I got:
@luanxuechao if you want you can also join the slack channel https://gofeatureflag.org/slack and we can discuss about your issue there.