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

push

parent 28e2ff2c
...@@ -73,13 +73,17 @@ public class ElasticRepositoryImpl implements IElasticRepository { ...@@ -73,13 +73,17 @@ public class ElasticRepositoryImpl implements IElasticRepository {
@PostConstruct @PostConstruct
private void postConstruct() throws Exception{ private void postConstruct() throws Exception{
K8sLocalParameterProvider provider = new K8sLocalParameterProvider(); K8sLocalParameterProvider provider = new K8sLocalParameterProvider();
host = provider.getParameterAsString(hostParameter); if (provider.getLocalMode()) {
port = Integer.parseInt(provider.getParameterAsString(portParameter)); // local mode, use the injected application.properties value for host and port etc
Type mapType = new TypeToken<Map<String, String>>(){}.getType(); }else {
Map<String, String> val = new Gson().fromJson(provider.getParameterAsString(elasticCredentialsSecret), mapType); host = provider.getParameterAsString(hostParameter);
username = val.get("username"); port = Integer.parseInt(provider.getParameterAsString(portParameter));
password = val.get("password"); Type mapType = new TypeToken<Map<String, String>>() {
}.getType();
Map<String, String> val = new Gson().fromJson(provider.getParameterAsString(elasticCredentialsSecret), mapType);
username = val.get("username");
password = val.get("password");
}
//elastic expects username:password format //elastic expects username:password format
usernameAndPassword = String.format("%s:%s", username, password); usernameAndPassword = String.format("%s:%s", username, password);
} }
......
...@@ -55,9 +55,6 @@ public class ElasticSettingServiceImpl implements IElasticSettingService { ...@@ -55,9 +55,6 @@ public class ElasticSettingServiceImpl implements IElasticSettingService {
@Value("${aws.elasticsearch.host}") @Value("${aws.elasticsearch.host}")
String hostParameter; String hostParameter;
@Value("${aws.elasticsearch.credentials.secret}")
String elasticCredentialsSecret;
@Value("${aws.region}") @Value("${aws.region}")
private String amazonRegion; private String amazonRegion;
...@@ -68,12 +65,9 @@ public class ElasticSettingServiceImpl implements IElasticSettingService { ...@@ -68,12 +65,9 @@ public class ElasticSettingServiceImpl implements IElasticSettingService {
K8sLocalParameterProvider provider = new K8sLocalParameterProvider(); K8sLocalParameterProvider provider = new K8sLocalParameterProvider();
host = provider.getParameterAsString(hostParameter); host = provider.getParameterAsString(hostParameter);
port = Integer.parseInt(provider.getParameterAsString(portParameter)); port = Integer.parseInt(provider.getParameterAsString(portParameter));
Type mapType = new TypeToken<Map<String, String>>(){}.getType(); Map<String, String>val = provider.getCredentialsAsMap("elasticsearch_credentials");
Map<String, String> val = new Gson().fromJson(provider.getParameterAsString(elasticCredentialsSecret), mapType); username = val.getOrDefault("username", username);
username = val.get("username").toString(); password = val.getOrDefault("password", password);
password = val.get("password").toString();
//elastic expects username:password format //elastic expects username:password format
usernameAndPassword = String.format("%s:%s", username, password); usernameAndPassword = String.format("%s:%s", username, password);
} }
......
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