spring-cloud / spring-cloud-vault

Configuration Integration with HashiCorp Vault
http://cloud.spring.io/spring-cloud-vault/
Apache License 2.0
275 stars 152 forks source link

org.springframework.cloud.bootstrap.BootstrapConfiguration deprecated ? #627

Closed neoludo closed 2 years ago

neoludo commented 2 years ago

Hi,

as bootstrap mechanism has been deprecated, and config data encouraged instead, how to migrate a class public class VaultPropertySourceInitializer implements ApplicationContextInitializer, BeanFactoryAware, Ordered

declared in spring.factories in org.springframework.cloud.bootstrap.BootstrapConfiguration property ?

Thanks in advance for your help. Ludo

mp911de commented 2 years ago

You can apply customizations through a Spring Boot Bootstrapper:

SpringApplication application = …;

application.addBootstrapper(VaultBootstrapper.fromConfigurer(configurer -> configurer.add("secret/customized")));
neoludo commented 2 years ago

Maybe it would be easier if I explain the feature I've implemented. via a file vault.yml : paths:

secrets declared in each path are loaded in Spring Context with prefixed bean (ex.: prefixA.mysecret, prefixB.mysecret). We have implemented this to avoid key collision.

Maybe you have a simplest approach to achieve it.

Thanks for your help Ludo

mp911de commented 2 years ago

In that case, you can use the Config import feature to remove the need for a customizer altogether. You can import individual config locations by adding these to the spring.config.import property, e.g.: spring.config.import=vault:pathA/subpathA?prefix=prefixA.,vault:pathB/subpathB?prefix=prefixB.

neoludo commented 2 years ago

Thanks a lot, it works like a charm !

On Mon, Jan 3, 2022 at 10:54 AM Mark Paluch @.***> wrote:

In that case, you can use the Config import feature to remove the need for a customizer altogether. You can import individual config locations by adding these to the spring.config.import property, e.g.: spring.config.import=vault:pathA/subpathA?prefix=prefixA,vault:pathA/subpathB?prefix=prefixB

— Reply to this email directly, view it on GitHub https://github.com/spring-cloud/spring-cloud-vault/issues/627#issuecomment-1003978292, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD76MMTRMBMEA6ZH5YVQNDUUFW6FANCNFSM5LEXPTWQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>