Skip to content

Commit d76d9f3

Browse files
Intro runtime env attrs (#286)
* removed secure connect url * Introduced Runtime Env Attributes Co-authored-by: Minal <[email protected]>
1 parent 3e31104 commit d76d9f3

File tree

8 files changed

+51
-11
lines changed

8 files changed

+51
-11
lines changed

obevo-core/src/main/java/com/gs/obevo/api/appdata/Environment.java

+14
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
*/
1616
package com.gs.obevo.api.appdata;
1717

18+
import java.util.Collection;
19+
import java.util.Collections;
1820
import java.util.LinkedHashSet;
21+
import java.util.Queue;
22+
import java.util.concurrent.ConcurrentLinkedQueue;
1923

2024
import com.gs.obevo.api.factory.PlatformConfiguration;
2125
import com.gs.obevo.api.platform.DeployerAppContext;
@@ -43,6 +47,7 @@ public class Environment<T extends Platform> {
4347
private T platform;
4448
private boolean cleanBuildAllowed = false;
4549
private ImmutableMap<String, String> tokens = Maps.immutable.empty();
50+
private ImmutableMap<String, String> runtimeEnvAttrs = Maps.immutable.empty();
4651
private String defaultUserId;
4752
private String defaultPassword;
4853
@Deprecated
@@ -68,6 +73,7 @@ public void copyFieldsFrom(Environment<T> env) {
6873
this.platform = env.platform;
6974
this.cleanBuildAllowed = env.cleanBuildAllowed;
7075
this.tokens = env.tokens;
76+
this.runtimeEnvAttrs = env.runtimeEnvAttrs;
7177
this.defaultUserId = env.defaultUserId;
7278
this.defaultPassword = env.defaultPassword;
7379
this.coreSourcePath = env.coreSourcePath;
@@ -137,6 +143,14 @@ public void setTokens(ImmutableMap<String, String> tokens) {
137143
this.tokens = tokens != null ? tokens : Maps.immutable.<String, String>empty();
138144
}
139145

146+
public ImmutableMap<String, String> getRuntimeEnvAttrs() {
147+
return this.runtimeEnvAttrs;
148+
}
149+
150+
public void setRuntimeEnvAttrs(ImmutableMap<String, String> runtimeEnvAttrs) {
151+
this.runtimeEnvAttrs = runtimeEnvAttrs != null ? runtimeEnvAttrs : Maps.immutable.<String, String>empty();
152+
}
153+
140154
/**
141155
* The main source path that was used to invoke this environment deployment. Used in case the paths are read in via
142156
* configuration and need to be resolved by some other executor.

obevo-core/src/main/java/com/gs/obevo/api/factory/XmlFileConfigReader.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private void postProcess(XMLConfiguration sysCfg) {
119119
"includeSchemas",
120120
"excludeSchemas"
121121
);
122-
ImmutableSet<String> ignorableSysNodes = Sets.immutable.of("excludeSchemas", "includeSchemas", "schemaOverrides", "tokens");
122+
ImmutableSet<String> ignorableSysNodes = Sets.immutable.of("excludeSchemas", "includeSchemas", "schemaOverrides", "tokens", "runtimeEnvAttrs");
123123
final ImmutableSet<String> ignorableEnvNodes = Sets.immutable.of("groups", "users");
124124
final ImmutableSet<String> ignorableEnvAttributes = Sets.immutable.of("sourceDirs", "acceptedExtensions", "dataDelimiter", "nullToken");
125125

obevo-core/src/main/java/com/gs/obevo/impl/AbstractEnvironmentEnricher.java

+14
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,20 @@ public String valueOf(ImmutableHierarchicalConfiguration tok) {
130130
});
131131
dbEnv.setTokens(tokens.toImmutable());
132132

133+
MutableMap<String, String> runtimeEnvAttrs = iterConfig(envCfg, "runtimeEnvAttrs.runtimeEnvAttr")
134+
.toMap(new Function<ImmutableHierarchicalConfiguration, String>() {
135+
@Override
136+
public String valueOf(ImmutableHierarchicalConfiguration tok) {
137+
return tok.getString("key");
138+
}
139+
}, new Function<ImmutableHierarchicalConfiguration, String>() {
140+
@Override
141+
public String valueOf(ImmutableHierarchicalConfiguration tok) {
142+
return tok.getString("value");
143+
}
144+
});
145+
dbEnv.setRuntimeEnvAttrs(runtimeEnvAttrs.toImmutable());
146+
133147
dbEnv.setRollbackDetectionEnabled(envCfg.getBoolean("rollbackDetectionEnabled", true));
134148

135149
Integer metadataLineReaderVersion = envCfg.getInteger("metadataLineReaderVersion", null);

obevo-db/src/main/java/com/gs/obevo/db/api/appdata/DbEnvironment.java

-10
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ public class DbEnvironment extends Environment<DbPlatform> {
5454
private String dbDataSourceName;
5555
private String driverClassName;
5656
private String defaultTablespace;
57-
private String secureConnectUrl;
5857

5958
private ImmutableList<Group> groups = Lists.immutable.empty();
6059
private ImmutableList<User> users = Lists.immutable.empty();
@@ -107,7 +106,6 @@ public void copyFieldsFrom(Environment baseEnv) {
107106
this.reorgCheckEnabled = env.reorgCheckEnabled;
108107
this.csvVersion = env.csvVersion;
109108
this.extraEnvAttrs = env.extraEnvAttrs;
110-
this.secureConnectUrl = env.secureConnectUrl;
111109
}
112110

113111
@Override
@@ -492,12 +490,4 @@ public ImmutableList<Extension> getExtensions() {
492490
public void setExtensions(ImmutableList<Extension> extensions) {
493491
this.extensions = extensions;
494492
}
495-
496-
public String getSecureConnectUrl() {
497-
return secureConnectUrl;
498-
}
499-
500-
public void setSecureConnectUrl(String secureConnectUrl) {
501-
this.secureConnectUrl = secureConnectUrl;
502-
}
503493
}

obevo-db/src/main/resources/deployer/xsd/system-config.xsd

+13
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,19 @@
8080
</xs:sequence>
8181
</xs:complexType>
8282
</xs:element>
83+
<xs:element name="runtimeEnvAttrs" minOccurs="0" maxOccurs="1">
84+
<xs:complexType>
85+
<xs:sequence>
86+
<xs:element name="runtimeEnvAttr" minOccurs="0"
87+
maxOccurs="unbounded">
88+
<xs:complexType>
89+
<xs:attribute name="key" type="xs:string" />
90+
<xs:attribute name="value" type="xs:string" />
91+
</xs:complexType>
92+
</xs:element>
93+
</xs:sequence>
94+
</xs:complexType>
95+
</xs:element>
8396
<xs:element name="permissions" minOccurs="0" maxOccurs="1" type="permissions" />
8497
</xs:sequence>
8598
<xs:attribute name="name" type="xs:string" use="required" />

obevo-db/src/test/java/com/gs/obevo/db/api/factory/DbEnvironmentXmlEnricherTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,8 @@ public String valueOf(PhysicalSchema physicalSchema) {
342342

343343
assertEquals("val", env1.getTokens().get("key"));
344344
assertEquals("val2", env1.getTokens().get("key2"));
345+
assertEquals("abc.com", env1.getRuntimeEnvAttrs().get("secureConnectUrl"));
346+
345347

346348
assertEquals(Lists.mutable.of(
347349
FileRetrievalMode.FILE_SYSTEM.resolveSingleFileObject("src/test/resources/DbEnvironmentXmlEnricher")

obevo-db/src/test/resources/DbEnvironmentXmlEnricher/system-config.xml

+3
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@
108108
<token key="key2" value="val2" />
109109
<token key="myProcGroupToken" value="detokenizedProcGroup" />
110110
</tokens>
111+
<runtimeEnvAttrs>
112+
<runtimeEnvAttr key="secureConnectUrl" value="abc.com" />
113+
</runtimeEnvAttrs>
111114
<auditTableSql>env specific
112115

113116
sql

obevo-db/src/test/resources/DbEnvironmentXmlEnricher/system-config.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ environments:
109109
key: key2
110110
- value: detokenizedProcGroup
111111
key: myProcGroupToken
112+
runtimeEnvAttrs:
113+
runtimeEnvAttr:
114+
- value: abc.com
115+
key: secureConnectUrl
112116
checksumDetectionEnabled: 'true'
113117
dbServer: dbServ
114118
defaultPassword: defPass

0 commit comments

Comments
 (0)