Add ability to resolve environment variables when reading 57/101857/3
authorSebastien Premont-Tendland <sebastien.premont@bell.ca>
Mon, 17 Feb 2020 23:05:05 +0000 (18:05 -0500)
committerSebastien Premont-Tendland <sebastien.premont@bell.ca>
Tue, 18 Feb 2020 19:04:29 +0000 (14:04 -0500)
PrimaryDatabaseConfiguration

This is needed to remove hardcoded password in application.properties
file by being able to resolve environment variables. OOM would pass the
username and password through environment variables.

Issue-ID: CCSDK-2095
Signed-off-by: Sebastien Premont-Tendland <sebastien.premont@bell.ca>
Change-Id: Ia19ef0ddee29509b0378b048bf58c700870ecce4

ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/BluePrintCoreConfiguration.kt

index 95b2c01..a86dcc4 100644 (file)
@@ -25,7 +25,6 @@ import org.slf4j.LoggerFactory
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.boot.context.properties.bind.Bindable
 import org.springframework.boot.context.properties.bind.Binder
-import org.springframework.boot.context.properties.source.ConfigurationPropertySources
 import org.springframework.context.ApplicationContext
 import org.springframework.context.ApplicationContextAware
 import org.springframework.context.annotation.Bean
@@ -55,18 +54,17 @@ open class BluePrintPropertyConfiguration {
 
     @Bean
     open fun bluePrintPropertyBinder(): Binder {
-        val configurationPropertySource = ConfigurationPropertySources.get(environment)
-        return Binder(configurationPropertySource)
+        return Binder.get(environment)
     }
 }
 
 @Service
-open class BluePrintPropertiesService(private var bluePrintPropertyBinder: Binder) {
+open class BluePrintPropertiesService(private var bluePrintPropertyConfig: BluePrintPropertyConfiguration) {
     private val log = logger(BluePrintPropertiesService::class)
 
     fun <T> propertyBeanType(prefix: String, type: Class<T>): T {
         return try {
-            bluePrintPropertyBinder.bind(prefix, Bindable.of(type)).get()
+            bluePrintPropertyConfig.bluePrintPropertyBinder().bind(prefix, Bindable.of(type)).get()
         } catch (e: NoSuchElementException) {
             val errMsg = "Error: missing property \"$prefix\"... Check the application.properties file."
             log.error(errMsg)