diff --git a/src/main/kotlin/Configs.kt b/src/main/kotlin/Configs.kt index b51f68a..f6145da 100644 --- a/src/main/kotlin/Configs.kt +++ b/src/main/kotlin/Configs.kt @@ -11,7 +11,6 @@ class Configs { loadPropertyFile("classpath:application.properties"), // default dev properties loadPropertyFile("classpath:application-local.properties"), // default personal properties (not versioned) loadPropertyFile("application.properties"), // file system properties (in production) - buildPropertiesFromEnv("PORT", "CUSTOM_MESSAGE") // environment variables always win ) fun loadPropertyFile(filePath: String): Properties { @@ -57,11 +56,14 @@ class Configs { return propsFromEnv; } - fun getProperty(propertyName: String): String { - return properties.getProperty(propertyName, "NONE"); + fun getProperty(propertyName: String, default: String = "NONE") : String { + return when(val value = System.getenv(propertyName)) { + null -> properties.getProperty(propertyName, default) + else -> value; + } } fun getIntegerProperty(propertyName: String): Int { - return Integer.parseInt(properties.getProperty(propertyName, "8080")); + return Integer.parseInt(getProperty(propertyName, "8080")); } }