From 082c2eccbc68ccdd8da5888630c937c626e487e6 Mon Sep 17 00:00:00 2001 From: Justin Field Date: Tue, 16 May 2017 16:00:59 -0700 Subject: [PATCH] Allow any property to be overridden by the props file generated by the CLI (#42) --- gradle.properties | 2 +- .../cerberus/server/config/CmsConfig.java | 22 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/gradle.properties b/gradle.properties index f8d4adaaf..86ad1c1ff 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,6 +14,6 @@ # limitations under the License. # -version=0.18.3 +version=0.19.0 groupId=com.nike.cerberus artifactId=cms diff --git a/src/main/java/com/nike/cerberus/server/config/CmsConfig.java b/src/main/java/com/nike/cerberus/server/config/CmsConfig.java index 348705455..86d7fb0ff 100644 --- a/src/main/java/com/nike/cerberus/server/config/CmsConfig.java +++ b/src/main/java/com/nike/cerberus/server/config/CmsConfig.java @@ -16,6 +16,7 @@ package com.nike.cerberus.server.config; +import com.google.inject.util.Modules; import com.nike.backstopper.handler.riposte.config.guice.BackstopperRiposteConfigGuiceModule; import com.nike.cerberus.server.config.guice.*; import com.nike.guice.PropertiesRegistrationGuiceModule; @@ -85,9 +86,16 @@ protected CmsConfig(Config appConfig, PropertiesRegistrationGuiceModule properti // Create a Guice Injector for this app. List appGuiceModules = new ArrayList<>(); appGuiceModules.add(propertiesRegistrationGuiceModule); - appGuiceModules.addAll(getAppGuiceModules(appConfig)); + appGuiceModules.addAll(Arrays.asList( + new CmsMyBatisModule(), + new BackstopperRiposteConfigGuiceModule(), + new CmsFlywayModule(), + new OneLoginGuiceModule() + )); - Injector appInjector = Guice.createInjector(appGuiceModules); + // bind the CMS Guice module last allowing the S3 props file to override any given application property + Injector appInjector = Guice.createInjector(Modules.override(appGuiceModules) + .with(new CmsGuiceModule(appConfig, objectMapper))); // Use the new Guice Injector to create a GuiceProvidedServerConfigValues, which will contain all the guice-provided config stuff for this app. this.guiceValues = appInjector.getProvider(GuiceProvidedServerConfigValues.class).get(); @@ -101,16 +109,6 @@ public CmsConfig(Config appConfig) { this(appConfig, new TypesafeConfigPropertiesRegistrationGuiceModule(appConfig)); } - protected List getAppGuiceModules(Config appConfig) { - return Arrays.asList( - new CmsGuiceModule(appConfig, objectMapper), - new CmsMyBatisModule(), - new BackstopperRiposteConfigGuiceModule(), - new CmsFlywayModule(), - new OneLoginGuiceModule() - ); - } - public static ObjectMapper configureObjectMapper() { final ObjectMapper om = new ObjectMapper(); om.findAndRegisterModules();