Commit acdf3fe9 authored by Bill Wang's avatar Bill Wang
Browse files

clean up

parent e2671f05
......@@ -55,35 +55,21 @@ public class ElasticRepositoryImpl implements IElasticRepository {
String usernameAndPassword;
@Value("${aws.elasticsearch.port}")
String portParameter;
@Value("${aws.elasticsearch.host}")
String hostParameter;
@Value("${aws.elasticsearch.credentials.secret}")
String elasticCredentialsSecret;
@Value("${aws.region}")
private String amazonRegion;
@PostConstruct
private void postConstruct() throws Exception{
K8sLocalParameterProvider provider = new K8sLocalParameterProvider();
if (provider.getLocalMode()) {
// local mode, use the injected application.properties value for host and port etc
}else {
host = provider.getParameterAsString(hostParameter);
port = Integer.parseInt(provider.getParameterAsString(portParameter));
Type mapType = new TypeToken<Map<String, String>>() {
}.getType();
Map<String, String> val = new Gson().fromJson(provider.getParameterAsString(elasticCredentialsSecret), mapType);
host = provider.getParameterAsStringOrDefault("elasticsearch_host", host);
port = Integer.parseInt(provider.getParameterAsStringOrDefault("elasticsearch_port", port));
Map<String, String>val = provider.getCredentialsAsMap("elasticsearch_credentials");
if (val != null){
username = val.get("username");
password = val.get("password");
}
//elastic expects username:password format
usernameAndPassword = String.format("%s:%s", username, password);
}
......
......@@ -45,26 +45,17 @@ public class ElasticSettingServiceImpl implements IElasticSettingService {
@Value("${aws.es.password}")
String password;
String usernameAndPassword;
@Value("${aws.elasticsearch.port}")
String portParameter;
@Value("${aws.elasticsearch.host}")
String hostParameter;
@Value("${aws.region}")
private String amazonRegion;
@Value("${aws.ssm}")
String ssmEnabledString;
@PostConstruct
private void postConstruct() throws Exception {
K8sLocalParameterProvider provider = new K8sLocalParameterProvider();
host = provider.getParameterAsString(hostParameter);
port = Integer.parseInt(provider.getParameterAsString(portParameter));
host = provider.getParameterAsStringOrDefault("elasticsearch_host", host);
port = Integer.parseInt(provider.getParameterAsStringOrDefault("elasticsearch_port", port));
Map<String, String>val = provider.getCredentialsAsMap("elasticsearch_credentials");
if (val != null){
username = val.get("username");
......
......@@ -55,9 +55,7 @@ awsParameterStorePropertySource.enabled=true
aws.ssm=${SSM_ENABLED}
aws.ssm.prefix=/osdu/${ENVIRONMENT}
aws.parameter.prefix=/osdu/${ENVIRONMENT}
aws.elasticsearch.host=elasticsearch_host
aws.elasticsearch.port=elasticsearch_port
aws.elasticsearch.credentials.secret=elasticsearch_credentials
server.ssl.enabled=${SSL_ENABLED:true}
server.ssl.key-store-type=PKCS12
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment