pip-services3-go / pip-services3-postgres-go

Postresql components for Pip.Services in Golang
MIT License
0 stars 0 forks source link

Feature/Bug - Use configuration parameters from ICredentialsStore #5

Closed antonio-alexander closed 3 years ago

antonio-alexander commented 3 years ago

I think this is more of a feature request and may go against the idea of the expected purpose of the code, there is a "bug", but with a few tweaks it's side effects could be useful feature for us.

https://github.com/pip-services3-go/pip-services3-postgres-go/blob/b1826291e3101cf4a5a07587cfa94ff54f0d4be3/connect/PostgresConnectionResolver.go#L240

Context

We created a component that reads data from vault and implements the Lookup method of the ICredentialStore interface such that we can provide it with secrets read from vault. This works excellent, except for an edge case where we also store some not so secret configuration options ALSO in vault.

We noticed that when we loaded values that would be output with the Lookup method of the credentials store, postgres would fail to connect because the URI would contain weird items that weren't valid for the connection string (e.g. "endpoint"). As a result we had to remove them, but we though it would be really nice, if we were able to pull configuration items such as the database name and host from vault as well, but alas it isn't possible due to how the code is organized.

Bug

I think it "could" be a "bug" that when generating the connection string we also use additional parameters from the credentials store

Feature

We'd like explicit support to be able to provide configuration items from the credentials store such that it could override configuration parameters. I think this could go against what was expected for that piece of code, but it'd save us a lot of effort and give us the ability to perform dynamic configuration without having to modify the environment (config.yml/environmental variables):

levichevdmitry commented 3 years ago

I'm not sure that I understand you correctly, could you please clarify from which source the parameters are more priority for you - from the configuration or the secrets store. If you can give a specific example of code that reflects this problem, then it would greatly speed up the process of solving it.

antonio-alexander commented 3 years ago

I talked with a co-worker and we found a better solution (that requires no changes from you guys), using the IDiscovery interface rather than trying to do it through the ICredentialsStore.