Skip to content
Snippets Groups Projects
Commit 335908f9 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-4453 add logging

parent 14352ddf
Branches
Tags
No related merge requests found
......@@ -16,7 +16,9 @@ import co.elastic.clients.json.jackson.JacksonJsonpMapper;
import co.elastic.clients.transport.rest_client.RestClientTransport;
import de.ozgcloud.operator.OzgCloudElasticsearchProperties;
import de.ozgcloud.operator.common.kubernetes.KubernetesRemoteService;
import lombok.extern.java.Log;
@Log
@Configuration
public class ElasticsearchClientConfiguration {
......@@ -28,6 +30,7 @@ public class ElasticsearchClientConfiguration {
@Bean
@Scope("singleton")
ElasticsearchClient createElasticsearchClient() {
log.info("Create elasticsearch client...");
var credentialsProvider = createCredentialsProvider(elasticSearchProperties.getServer().getSecretDataKey(), getPassword());
var restClient = buildRestClient(credentialsProvider);
var transport = createRestClientTransport(restClient);
......@@ -37,6 +40,7 @@ public class ElasticsearchClientConfiguration {
private BasicCredentialsProvider createCredentialsProvider(String userName, String password) {
var credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(userName, password));
log.info(String.format("use credentials: username: %s, password: %s", userName, password));
return credentialsProvider;
}
......@@ -47,6 +51,7 @@ public class ElasticsearchClientConfiguration {
}
private HttpHost createHttpHost() {
log.info(String.format("use host: %s with port: %s and scheme: %s", elasticSearchProperties.getServer().getHost(), elasticSearchProperties.getServer().getPort(), elasticSearchProperties.getServer().getScheme()));
return new HttpHost(elasticSearchProperties.getServer().getHost(), elasticSearchProperties.getServer().getPort(), elasticSearchProperties.getServer().getScheme());
}
......@@ -55,8 +60,10 @@ public class ElasticsearchClientConfiguration {
}
String getPassword() {
log.info(String.format("get password from secret: %s in namespace %s", elasticSearchProperties.getServer().getNamespace(), elasticSearchProperties.getServer().getSecretName()));
var resource = kubernetesService.getSecretResource(elasticSearchProperties.getServer().getNamespace(), elasticSearchProperties.getServer().getSecretName());
var password = MapUtils.getString(resource.get().getStringData(), elasticSearchProperties.getServer().getSecretDataKey());
log.info(String.format("used password: %s", password));
return password;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment