dave08
07/04/2021, 12:54 PMfun ConfigLoader.Builder.addSourceIf(source: PropertySource, condition: () -> Boolean) = apply {
if (condition()) addSource(source)
}
My use case:
ConfigLoader.Builder()
.addSource(PropertySource.resource("/application.yaml"))
.addSourceIf(PropertySource.resource("/application-k8s.yaml", true)) {
System.getenv().containsKey("KUBERNETES_SERVICE_HOST")
}
.build()
.loadConfigOrThrow()
To load a k8s config file if in k8s.