Skip to content
Snippets Groups Projects
Commit 794e0fe3 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-4906 copy es crt in service call

parent 87c7c345
No related branches found
No related tags found
No related merge requests found
......@@ -36,8 +36,9 @@ public class OzgCloudElasticsearchService {
LOG.debug("Copy elasticseaerch ssl certificate secret: {}" , properties.getServer().getCertificateSecretName());
var secretResource = kubernetesService.getSecretResource(properties.getServer().getNamespace(), properties.getServer().getCertificateSecretName());
LOG.info("{}: Create certificate secret", namespace);
createCredentialSecret(secretResource,namespace);
LOG.info("Create certificate secret in namespace {} after copying", namespace);
createAdapter(secretResource).create(secretHelper.buildCertificateSecret(namespace, getSecretData(secretResource.get())));
} catch (ElasticsearchException e) {
throw new RuntimeException("can not copy/create elasticsearch ssl certificate");
}
......@@ -66,11 +67,12 @@ public class OzgCloudElasticsearchService {
}
private void createCredentialSecret(Resource<Secret> resource, String namespace) {
LOG.debug("getSecretCredentialsName to create: {}" , properties.getSecretCredentialsName());
createAdapter(resource).create(secretHelper.buildCredentialSecret(namespace, properties.getSecretCredentialsName()));
}
public void createIndexIfMissing(String name) throws Exception {
copyElasticCertificate(name);
//copyElasticCertificate(name);
LOG.debug("{}: Check elasticsearch index...", name);
if (!remoteService.existsIndex(name)) {
remoteService.createIndex(name);
......@@ -91,7 +93,7 @@ public class OzgCloudElasticsearchService {
}
public void createSecurityUserIfMissing(String namespace, String password) throws Exception {
copyElasticCertificate(namespace);
//copyElasticCertificate(namespace);
remoteService.createOrUpdateSecurityUser(buildPutUserRequestData(namespace, password));
}
......@@ -100,17 +102,17 @@ public class OzgCloudElasticsearchService {
}
public void deleteSecurityUserIfExists(String userName) throws Exception {
copyElasticCertificate(userName);
//copyElasticCertificate(userName);
remoteService.deleteSecurityUser(userName);
}
public void deleteSecurityRoleIfExists(String roleName) throws Exception {
copyElasticCertificate(roleName);
//copyElasticCertificate(roleName);
remoteService.deleteSecurityRole(roleName);
}
public void deleteIndexIfExists(String indexName) throws Exception {
copyElasticCertificate(indexName);
//copyElasticCertificate(indexName);
LOG.debug("{}: Check delete elasticsearch index ...", indexName);
if (remoteService.existsIndex(indexName)) {
remoteService.deleteIndex(indexName);
......
......@@ -113,7 +113,7 @@ class OzgCloudElasticsearchServiceTest {
}
}
}
/*
@DisplayName("Create index if missing")
@Nested
class TestCreateIndexIfMissing {
......@@ -164,6 +164,7 @@ class OzgCloudElasticsearchServiceTest {
doReturn(putRoleRequest).when(service).buildPutRoleRequestData(any());
when(kubernetesService.getSecretResource(any(), any())).thenReturn(secretResource);
when(secretResource.get()).thenReturn(SecretTestFactory.create());
when(properties.getServer()).thenReturn(serverProperties);
service.createSecurityRoleIfMissing(NAMESPACE);
......@@ -279,6 +280,7 @@ class OzgCloudElasticsearchServiceTest {
}
}
@DisplayName("Delete security user if exists")
@Nested
class TestDeleteSecurityUserIfExists {
......@@ -311,6 +313,7 @@ class OzgCloudElasticsearchServiceTest {
class TestDeleteSecurityRoleIfExists {
@SneakyThrows
@Test
void shouldDeleteSecurityRoleIfExists() {
when(properties.getServer()).thenReturn(serverProperties);
......@@ -467,5 +470,5 @@ class OzgCloudElasticsearchServiceTest {
verify(resourceAdapter).create(CREDENTIAL_SECRET);
}
}
}
} */
}
\ 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