gitlifangyuan commented on issue #5700:
URL: https://github.com/apache/seatunnel/issues/5700#issuecomment-1966066931
Try it this way. Note that this is not a fundamental solution to the problem
,a temporary solution to the problem. Change the method: ConfigShadeUtils
processConfig() Then install 《the seatunnel-core-starter》 module
```
@SuppressWarnings("unchecked")
private static Config processConfig(String identifier, Config config,
boolean isDecrypted) {
ConfigShade configShade = CONFIG_SHADES.getOrDefault(identifier,
DEFAULT_SHADE);
List<String> sensitiveOptions = new
ArrayList<>(Arrays.asList(DEFAULT_SENSITIVE_OPTIONS));
sensitiveOptions.addAll(Arrays.asList(configShade.sensitiveOptions()));
BiFunction<String, Object, String> processFunction =
(key, value) -> {
if (isDecrypted) {
return configShade.decrypt(value.toString());
} else {
return configShade.encrypt(value.toString());
}
};
String jsonString =
config.root().render(ConfigRenderOptions.concise());
ObjectNode jsonNodes = JsonUtils.parseObject(jsonString);
Map<String, Object> configMap = JsonUtils.toMap(jsonNodes);
List<Map<String, Object>> sources = new ArrayList<>();
try {
sources = (ArrayList<Map<String, Object>>)
configMap.get(Constants.SOURCE);
} catch (ClassCastException e) {
log.info("ClassCastException : " + e.getMessage() );
Map<String, Object> tmp = (Map<String, Object>)
configMap.get(Constants.SOURCE);
for (String key : tmp.keySet()) {
Map<String, Object> tmp1 = (Map<String, Object>)
tmp.get(key);
tmp1.put("plugin_name",key);
sources.add(tmp1);
}
}
List<Map<String, Object>> sinks = new ArrayList<>();
try {
sinks = (ArrayList<Map<String, Object>>)
configMap.get(Constants.SINK);
} catch (ClassCastException e) {
log.info("ClassCastException : " + e.getMessage() );
Map<String, Object> tmp = (Map<String,
Object>)configMap.get(Constants.SINK);
for (String key : tmp.keySet()) {
Map<String, Object> tmp1 = (Map<String, Object>)
tmp.get(key);
tmp1.put("plugin_name",key);
sinks.add(tmp1);
}
}
List<Map<String, Object>> transform = new ArrayList<>();
try {
transform = (ArrayList<Map<String, Object>>)
configMap.get(Constants.TRANSFORM);
} catch (ClassCastException e) {
log.info("ClassCastException : " + e.getMessage() );
Map<String, Object> tmp = (Map<String,
Object>)configMap.get(Constants.TRANSFORM);
for (String key : tmp.keySet()) {
Map<String, Object> tmp1 = (Map<String, Object>)
tmp.get(key);
tmp1.put("plugin_name",key);
transform.add(tmp1);
}
}
Preconditions.checkArgument(
!sources.isEmpty(), "Miss <Source> config! Please check the
config file.");
Preconditions.checkArgument(
!sinks.isEmpty(), "Miss <Sink> config! Please check the
config file.");
sources.forEach(
source -> {
for (String sensitiveOption : sensitiveOptions) {
source.computeIfPresent(sensitiveOption,
processFunction);
}
});
sinks.forEach(
sink -> {
for (String sensitiveOption : sensitiveOptions) {
sink.computeIfPresent(sensitiveOption,
processFunction);
}
});
configMap.put(Constants.SOURCE, sources);
configMap.put(Constants.TRANSFORM, transform);
configMap.put(Constants.SINK, sinks);
return ConfigFactory.parseMap(configMap);
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]