Is it possible to add config locations without specifying spring.config.import in application.properties file?
Spring Boot adds default config locations in ConfigDataEnvironmentPostProcessor, e.g., classpath: and file:. I tried to do this in #1561, yet it has some problems:
-
I have to increase the order of
GcpSecretManagerEnvironmentPostProcessorso thatspring.config.import=sm://can be added in the config location list byConfigDataEnvironmentPostProcessor. However, other related properties, e.g.,spring.cloud.gcp.secretmanager.allow-default-secret=truedon't get parsed when initiatingGcpSecretManagerProperties. I'm guessingConfigDataEnvironmentPostProcessorgets called early soapplication.propertiesis not available yet. -
spring-cloud-gcp-secretmanagerdependency is required in the class path even if the user doesn't use it since resolving the config locationsm://always end up creating Secret Manager beans.
cc: @meltsufin
Comment From: philwebb
The spring.config.import property is pretty special, it's not designed to be used outside of the file that defines it. This is because you can have an import which itself then triggers another import.
I'm not sure exactly how your secrets management works so I can't offer any concrete advice. You might be able to change your GcpSecretManagerEnvironmentPostProcessor so that it has a constructor that accepts a ConfigurableBootstrapContext. If it was ordered after ConfigDataEnvironmentPostProcessor you could do logic similar to SecretManagerConfigDataLocationResolver to register things.