confd
confd copied to clipboard
confd config prefix vs resource prefix
Thank you so much for maintaining this fork!
Currently confd config prefix overrides the template resource prefix, which seems counter-intuitive:
https://github.com/abtreece/confd/blob/8a76b9a4a11a7ee55682724b0fce537d350e2ead/pkg/template/resource.go#L93
Scenario:
- Set
prefix
in/etc/confd/confd.toml
toproduction
- Set
prefix
in/etc/confd/conf.d/myapp.toml
tomyapp
- Set
prefix
in/etc/confd/conf.d/yourapp.toml
toyourapp
Current behaviour:
Debug logs:
DEBUG Loading template resource from /etc/confd/conf.d/myapp.toml
DEBUG Retrieving keys from store
DEBUG Key prefix set to /production
DEBUG Processing key=/production/foo
DEBUG Loading template resource from /etc/confd/conf.d/yourapp.toml
DEBUG Retrieving keys from store
DEBUG Key prefix set to /production
DEBUG Processing key=/production/foo
Expected behaviour:
Debug logs:
DEBUG Loading template resource from /etc/confd/conf.d/myapp.toml
DEBUG Retrieving keys from store
DEBUG Key prefix set to /production/myapp
DEBUG Processing key=/production/myapp/foo
DEBUG Loading template resource from /etc/confd/conf.d/yourapp.toml
DEBUG Retrieving keys from store
DEBUG Key prefix set to /production/yourapp
DEBUG Processing key=/production/yourapp/foo
Does this make sense? is there a reason/use-case I'm missing?
I realize changing this would be a breaking change, so I'm not sure if you would consider this?
Suggestion
if tr.Prefix
is set, concat with config.Prefix
🤔
It appears the behavior was modified in this PR. I think this is the appropriate behavior for the CLI, but I'm not sure there is a reason why "nested" prefixes of the .toml configs couldn't be concatenated.