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

VaultConfigSource in quarkus-vault cannot be configured with properties requiring property expansion #10390

Closed
knutwannheden opened this issue Jul 1, 2020 · 11 comments · Fixed by #12834
Labels
area/vault kind/bug Something isn't working
Milestone

Comments

@knutwannheden
Copy link
Contributor

Describe the bug
The VaultConfigSource code doesn't use the Config#getValue() API to read its own config properties. Instead it uses Config#getConfigSources() and manually extracts the config values from these ConfigSources. (Presumably this is because there would otherwise be an endless recursion which would have to be addressed.) As a consequence, however, the corresponding config properties can not be configured with values which require property expansion, since VaultConfigSource doesn't contain the logic to do the property expansion.

I think that VaultConfigSource should try to directly use Config#getValue(). That would probably require logic to detect and avoid an endless recursion in VaultConfigSource#getValue(String). Or can SmallRyeConfigBuilder be used (subclassed?) somehow to avoid the recursion?

Expected behavior
VaultConfigSource should also be configurable with property values requiring property expansion. E.g.

my-vault-host=localhost
quarkus.vault.url=http://${my-vault-host}:8200

Actual behavior
Specifying config values which require expansion doesn't work.

To Reproduce
See above.

Configuration
See above.

@knutwannheden knutwannheden added the kind/bug Something isn't working label Jul 1, 2020
@sberyozkin
Copy link
Member

CC @vsevel @radcortez (Roberto, may be you can suggest some latest config feature)

@radcortez
Copy link
Member

Yes, we just added a feature in SmallRye Config that allows a ConfigSource to configure itself:
https://smallrye.io/docs/smallrye-config/config-sources/config-sources.html

https://github.com/smallrye/smallrye-config/blob/master/implementation/src/main/java/io/smallrye/config/ConfigSourceFactory.java

This allows you to create the ConfigSource and access a ConfigSourceContext object that has access to the ConfigSources already initialized. These are the ConfigSources with higher priority than the Factory.

@radcortez
Copy link
Member

This is not released yet, so we may need a few more days to release and update Quarkus.

@knutwannheden
Copy link
Contributor Author

That sounds interesting. Certainly something we could also use in a custom ConfigSource implementation in our project.

@sberyozkin
Copy link
Member

@radcortez Super

@vsevel
Copy link
Contributor

vsevel commented Jul 10, 2020

smallrye/smallrye-config#196 was fixed by smallrye/smallrye-config#313 as part of milestone 1.9.0. waiting for the release.

@radcortez
Copy link
Member

We are finally here :)

Sorry for taking so much time, we were working on another big feature that took longer to complete. PR is opened for 1.9.0. When we are done with that, you can configure ConfigSources in this way:
https://smallrye.io/docs/smallrye-config/config-sources/config-sources.html

Or if you prefer to see some code, I've updated the ZooKeeper source to use this:
https://github.com/smallrye/smallrye-config/tree/master/sources/zookeeper/src/main/java/io/smallrye/config/source/zookeeper

@knutwannheden
Copy link
Contributor Author

Very cool!

@vsevel
Copy link
Contributor

vsevel commented Sep 22, 2020

@radcortez hello. I have started to look at the new feature. I am missing the capability to list all properties given a particular prefix (e.g. quarkus.vault.), for instance when building the list of vault paths.
is there a better way to do it? if not do you think that is something that could be added?
from what I see however, this would still require the VaultConfigSourceFactory to recode the logic of building the config objects that are normally built by quarkus. in that sense, #4848 would have been a much better option I believe.

@radcortez
Copy link
Member

We already have that, is just not exposed in the ConfigSourceContext API. It should be fairly easy to add the list of properties as well.

Yes, the Factory will handle the init code. I haven't tried to use it as a build step, but we should be able to record it as a ServiceProvider. We need to try that.

@radcortez
Copy link
Member

@vsevel let me know if this works for you: smallrye/smallrye-config#402

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/vault kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants