Open juriohacc opened 1 year ago
Applying customizations in the early application startup (before starting SpringApplication.run(…)
) to not have access to PropertySources
or Environment
because these objects do not yet exist. Paging @mhalbritter from the Boot team, whether we have a chance to get hold of the config data in an early startup stage to apply customizations before ConfigDataLoader
is being activated.
So, do you mean that even for using the new method you added in https://github.com/spring-projects/spring-vault/issues/760 : createHttpAsyncClientBuilder, it's necessary to create ourself the ClientOptions and SslConfiguration, it cannot be provided by Spring Vault ?
Ok for the access of PropertySources/Environment , i'm going to see with @mhalbritter what it's possible to do.
Normally an Environment
is created for you when you call run
. That means before run
is called, there is no Environment
available. However, you can use setEnvironment()
on the SpringApplication
to set a custom environment (this can be done before calling run
). This environment is then used for startup, too. Not sure if this helps your usecase.
Ideally, we could create an Environment
with all the file-based and env-variable property sources that mimic Spring Boot's Environment
for binding @ConfigurationProperties
.
The alternative could be a customization hook in Spring Cloud Vault via InstanceSupplier
that is leveraged by our ConfigDataLocationResolver
or ConfigDataLoader
to customize infrastructure components such as the HTTP client.
It basically boils down to being able to customize ConfigDataLoader
before the application startup. I'm going to spend a few cycles on this approach to come up with a design idea.
Hello,
As i have already mentioned the need to configure http client connection TTL for spring cloud vault (https://github.com/spring-cloud/spring-cloud-vault/issues/660), i need to find the good way to do it.
You gave us a way to do it : https://gist.github.com/mp911de/157e6ae14ba6bb3565c36b425d3d83b7 However, even if the class HttpComponents become public, there is no method getBuilder()
Here is the static class HttpComponents in ClientHttpRequestFactoryFactory :
The only method available from this static class HttpComponents is usingHttpComponents but this method need some parameters (clientOptions and SslConfiguration) and return ClientHttpRequestFactory This method does not let configure the HttpClientBuilder and from Spring Boot main method. How could we get the clientOptions and SslConfiguration which necessitate to inject VaultProperties.
This is a code i have done, do you have a better way before wait for the change apply in new spring vault core version about visibility of HttpComponents ?
Here is the code i have done :
there are some missing parts, how inject VaultProperties data to configure the ClientOption and SslConfiguration before run the application as you its done in spring vault ? I will need to use multiple properties from spring configuration application as value of connectionTimeToLive, retry flag, .. and retrieve these properties does not seem be possible because spring context is not yes defined
Thank you.