confd icon indicating copy to clipboard operation
confd copied to clipboard

confd config prefix vs resource prefix

Open vincentgna opened this issue 2 years ago • 2 comments

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:

  1. Set prefix in /etc/confd/confd.toml to production
  2. Set prefix in /etc/confd/conf.d/myapp.toml to myapp
  3. Set prefix in /etc/confd/conf.d/yourapp.toml to yourapp

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

vincentgna avatar Aug 20 '22 13:08 vincentgna

🤔

abtreece avatar Sep 08 '22 13:09 abtreece

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.

abtreece avatar Sep 09 '22 04:09 abtreece