jdiazcano / cfg4k

Flexible and easy to use config library written in kotlin
Apache License 2.0
80 stars 6 forks source link

Vault Config #49

Open tobad357 opened 6 years ago

tobad357 commented 6 years ago

I would be interested to load configs from Vault Would that be best implemented as a source or a provider?

jdiazcano commented 6 years ago

I am unsure how Vault works. But here's more or less the rule of thumb.

A source is what gives you a Stream of the data bytes that will be read by a Loader. As I am not sure how Vault works, could you tell me what it returns when asking for something?

tobad357 commented 6 years ago

If using the Vault Java Client then it returns a String

// Read operation
final String value = vault.logical()
                       .read("secret/hello")
                       .getData().get("value");

JavaDoc Java Client

jdiazcano commented 6 years ago

Then you can use it as a Loader. The loader will just return the raw data and the provider is the one that will present it to you in a nice way.

But you need to do one change that is transforming the data. Right now it used dots as separator so you would have to transform it into slashes before querying vault