Skip to content

Commit 1504810

Browse files
authored
Merge pull request #16 from Optum/convert-periods-to-underscore
Convert periods to underscore
2 parents cdd6b4d + 059d392 commit 1504810

File tree

9 files changed

+16
-18
lines changed

9 files changed

+16
-18
lines changed

envvars-cli/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>com.optum.envvars</groupId>
1010
<artifactId>envvars</artifactId>
11-
<version>3.1.X-SNAPSHOT</version>
11+
<version>3.2.X-SNAPSHOT</version>
1212
<relativePath>../pom.xml</relativePath>
1313
</parent>
1414

envvars-json/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>com.optum.envvars</groupId>
1010
<artifactId>envvars</artifactId>
11-
<version>3.1.X-SNAPSHOT</version>
11+
<version>3.2.X-SNAPSHOT</version>
1212
<relativePath>../pom.xml</relativePath>
1313
</parent>
1414

@@ -28,7 +28,7 @@
2828
<dependency>
2929
<groupId>com.optum.envvars</groupId>
3030
<artifactId>envvars-lib</artifactId>
31-
<version>3.1.X-SNAPSHOT</version>
31+
<version>3.2.X-SNAPSHOT</version>
3232
</dependency>
3333
<dependency>
3434
<groupId>com.fasterxml.jackson.core</groupId>

envvars-lib/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>com.optum.envvars</groupId>
1010
<artifactId>envvars</artifactId>
11-
<version>3.1.X-SNAPSHOT</version>
11+
<version>3.2.X-SNAPSHOT</version>
1212
<relativePath>../pom.xml</relativePath>
1313
</parent>
1414

envvars-lib/src/main/java/com/optum/envvars/mapdata/EnvVarsMapDataEngine.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,23 +169,21 @@ void addEnvVarsForDefaultSelector(Map previousScope, EnvVarsMapData envVarsData,
169169
* @return The scope of the selector, if found, otherwise null.
170170
*/
171171
Map addEnvVarsForSelectorImpl(Map previousScope, EnvVarsMapData envVarsData, EnvVarsRuntimeSelectors.Node node, String selector, boolean required) throws EnvVarsException {
172-
final String messageContext = "[" + node.context + ":" + selector + "]";
173-
174172
/////////////////////////////////////
175173
// We start by looking for a SELECTOR
176174
/////////////////////////////////////
177175
Object currentScopeObject = previousScope.get(selector);
178176
if ((currentScopeObject == null)) {
179177
if (required) {
180-
throw new EnvVarsException("Unable to find " + messageContext + " which is required.");
178+
throw new EnvVarsException("Missing selector \"" + selector + "\". Unable to find an element named \"" + selector + "\" inside the node \"" + node.context + "\", and rules for this node require that it exists.");
181179
} else {
182180
// Selector not found. Selector not required. Do nothing, and be happy about it.
183181
return null;
184182
}
185183
}
186184

187185
if (!(currentScopeObject instanceof Map)) {
188-
throw new EnvVarsException("The element " + messageContext + " must be a map, but it is not.");
186+
throw new EnvVarsException("Invalid selector \"" + selector + "\". The element \"" + selector + "\" inside the node \"" + node.context + "\" must be a map, but it is not.");
189187
}
190188

191189
Map currentScope = (Map)currentScopeObject;
@@ -266,7 +264,7 @@ private static Map<String, String> processCurrentScopeMap(String mapName, Map cu
266264
}
267265

268266
if (!(envvarsObject instanceof Map)) {
269-
throw new EnvVarsException("The element " + messageContext + " must be a map, but it is not.");
267+
throw new EnvVarsException("Invalid context \"" + mapName + "\". The element \"" + mapName + "\" inside the selector \"" + selector + "\" inside the node \"" + node.context + "\" must be a map, but it is not.");
270268
}
271269

272270
Map<String, String> results = new HashMap<>();

envvars-lib/src/main/java/com/optum/envvars/set/EnvVarsStaticSets.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private boolean argSwap(int argNumber, String value, List<String> strings) {
144144
StringBuilder sb = new StringBuilder(prefix.length() + value.length() + suffix.length());
145145
sb.append(prefix);
146146
if (toUpper) {
147-
sb.append(value.toUpperCase().replace("-", "_"));
147+
sb.append(value.toUpperCase().replace("-", "_").replace(".", "_"));
148148
} else if (toLower) {
149149
sb.append(value.toLowerCase().replace("_", "-"));
150150
} else {

envvars-lib/src/test/groovy/com/optum/envvars/EnvVarEngineSpec.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class EnvVarEngineSpec extends Specification {
7575

7676
then:
7777
EnvVarsException ex = thrown()
78-
ex.message == 'Unable to find [environments:missing] which is required.'
78+
ex.message == 'Missing selector "missing". Unable to find an element named "missing" inside the node "environments", and rules for this node require that it exists.'
7979
}
8080

8181
def "SELECTOR: Missing optional selector"() {

envvars-lib/src/test/groovy/com/optum/envvars/EnvVarMapDataEngineSpec.groovy

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class EnvVarMapDataEngineSpec extends Specification {
6565

6666
then:
6767
EnvVarsException ex = thrown()
68-
ex.message == 'Unable to find [environments:missing] which is required.'
68+
ex.message == 'Missing selector "missing". Unable to find an element named "missing" inside the node "environments", and rules for this node require that it exists.'
6969
}
7070

7171
def "SELECTOR: Missing optional selector" () {
@@ -108,7 +108,7 @@ class EnvVarMapDataEngineSpec extends Specification {
108108

109109
then:
110110
EnvVarsException ex = thrown()
111-
ex.message == 'The element [environments:env1:define] must be a map, but it is not.'
111+
ex.message == 'Invalid context "define". The element "define" inside the selector "env1" inside the node "environments" must be a map, but it is not.'
112112
}
113113

114114
def "BLOCK: Bad secretEnvvars" () {
@@ -119,7 +119,7 @@ class EnvVarMapDataEngineSpec extends Specification {
119119

120120
then:
121121
EnvVarsException ex = thrown()
122-
ex.message == 'The element [environments:env2:defineSecrets] must be a map, but it is not.'
122+
ex.message == 'Invalid context "defineSecrets". The element "defineSecrets" inside the selector "env2" inside the node "environments" must be a map, but it is not.'
123123
}
124124

125125
def "BLOCK: Bad injectEnvvars" () {
@@ -152,7 +152,7 @@ class EnvVarMapDataEngineSpec extends Specification {
152152

153153
then:
154154
EnvVarsException ex = thrown()
155-
ex.message == 'The element [environments:badenv] must be a map, but it is not.'
155+
ex.message == 'Invalid selector "badenv". The element "badenv" inside the node "environments" must be a map, but it is not.'
156156
}
157157
/**
158158
* Three different flows, so each test in each of these blocks: envvars, injectedEnvvars, injectedQualifiedEnvvars.
@@ -465,7 +465,7 @@ class EnvVarMapDataEngineSpec extends Specification {
465465

466466
then:
467467
EnvVarsException ex = thrown()
468-
ex.message == 'Unable to find [applications:default] which is required.'
468+
ex.message == 'Missing selector "default". Unable to find an element named "default" inside the node "applications", and rules for this node require that it exists.'
469469
}
470470

471471
final Map envKeys = new JsonSlurper().parseText("""{

envvars-yaml/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>com.optum.envvars</groupId>
1010
<artifactId>envvars</artifactId>
11-
<version>3.1.X-SNAPSHOT</version>
11+
<version>3.2.X-SNAPSHOT</version>
1212
<relativePath>../pom.xml</relativePath>
1313
</parent>
1414

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.optum.envvars</groupId>
88
<artifactId>envvars</artifactId>
9-
<version>3.1.X-SNAPSHOT</version>
9+
<version>3.2.X-SNAPSHOT</version>
1010
<packaging>pom</packaging>
1111

1212
<name>envvars</name>

0 commit comments

Comments
 (0)