Skip to content

Commit 54d58bd

Browse files
committed
Fix #34169: rename cloudwatch property
1 parent a132b58 commit 54d58bd

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/main/java/eu/openanalytics/containerproxy/backend/ecs/EcsBackend.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public void initialize() {
134134
securityGroups = EnvironmentUtils.readList(environment, "proxy.ecs.security-groups");
135135
totalWaitMs = environment.getProperty(PROPERTY_PREFIX + PROPERTY_SERVICE_WAIT_TIME, Integer.class, 180000);
136136

137-
enableCloudWatch = environment.getProperty("proxy.ecs.enable-cloudwatch", Boolean.class, false);
137+
enableCloudWatch = EnvironmentUtils.getProperty(environment, "proxy.ecs.enable-cloud-watch", "proxy.ecs.enable-cloudwatch", Boolean.class, false);
138138
cloudWatchGroupPrefix = environment.getProperty("proxy.ecs.cloud-watch-group-prefix", String.class, "/ecs/");
139139
cloudWatchRegion = environment.getProperty("proxy.ecs.cloud-watch-region", String.class, getProperty(PROPERTY_REGION));
140140
cloudWatchStreamPrefix = environment.getProperty("proxy.ecs.cloud-watch-stream-prefix", String.class, "ecs");

src/main/java/eu/openanalytics/containerproxy/util/EnvironmentUtils.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,22 @@ public static List<String> readList(Environment environment, String propertyName
7070
return result;
7171
}
7272

73+
/**
74+
* Reads a property from the environment (i.e. config file). Supports reading a fallback property.
75+
* This is useful to rename properties.
76+
* @param environment environment to read the property from
77+
* @param propertyName property name
78+
* @param fallbackPropertyName property name used when no value found
79+
* @param targetType the expected type of the property value
80+
* @param defaultValue the default value to return if no value is found
81+
* @return the property value or null
82+
*/
83+
public static <T> T getProperty(Environment environment, String propertyName, String fallbackPropertyName, Class<T> targetType, T defaultValue) {
84+
T result = environment.getProperty(propertyName, targetType);
85+
if (result != null) {
86+
return result;
87+
}
88+
return environment.getProperty(fallbackPropertyName, targetType, defaultValue);
89+
}
90+
7391
}

0 commit comments

Comments
 (0)