Commit 00a3bfcc authored by Aliaksei Darafeyeu's avatar Aliaksei Darafeyeu
Browse files

gets redis-host

parent 4bb31fd5
Pipeline #24600 failed with stages
in 2 minutes and 15 seconds
......@@ -14,12 +14,14 @@
package org.opengroup.osdu.storage.provider.azure.di;
import org.opengroup.osdu.azure.KeyVaultFacade;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import javax.inject.Named;
import com.azure.security.keyvault.secrets.SecretClient;
@Component
public class AzureBootstrapConfig {
......@@ -27,6 +29,12 @@ public class AzureBootstrapConfig {
@Value("${azure.servicebus.topic-name}")
private String serviceBusTopic;
@Value("${azure.keyvault.url}")
private String keyVaultURL;
@Value("${azure.cosmosdb.database}")
private String cosmosDBName;
@Bean
@Named("STORAGE_CONTAINER_NAME")
public String containerName() {
......@@ -39,12 +47,6 @@ public class AzureBootstrapConfig {
return serviceBusTopic;
}
@Value("${azure.keyvault.url}")
private String keyVaultURL;
@Value("${azure.cosmosdb.database}")
private String cosmosDBName;
@Bean
@Named("KEY_VAULT_URL")
public String keyVaultURL() {
......
......@@ -14,6 +14,9 @@
package org.opengroup.osdu.storage.provider.azure.di.cache;
import javax.inject.Named;
import org.opengroup.osdu.azure.KeyVaultFacade;
import org.opengroup.osdu.core.common.cache.RedisCache;
import org.opengroup.osdu.core.common.model.entitlements.Groups;
import org.opengroup.osdu.core.common.model.storage.Schema;
......@@ -22,16 +25,27 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.azure.security.keyvault.secrets.SecretClient;
@Configuration
public class RedisConfig {
@Value("${redis.host}")
private String redisHost;
@Bean
@Named("REDIS_HOST")
public String redisHost(SecretClient kv) {
if (redisHost == null || redisHost.isEmpty()) {
redisHost = KeyVaultFacade.getSecretWithValidation(kv, "redis-hostname");
}
return redisHost;
}
@Configuration
@ConditionalOnExpression(value = "'${cache.provider}' == 'redis' && '${redis.ssl.enabled:false}'")
static class SslConfig {
@Value("${redis.host}")
private String host;
@Value("${redis.port}")
private int port;
......@@ -45,17 +59,17 @@ public class RedisConfig {
private String password;
@Bean
public RedisCache<String, Groups> groupCache() {
public RedisCache<String, Groups> groupCache(@Named("REDIS_HOST") String host) {
return new RedisCache<>(host, port, password, expiration, database, String.class, Groups.class);
}
@Bean("legalTagCache")
public RedisCache<String, String> legalTagCache() {
public RedisCache<String, String> legalTagCache(@Named("REDIS_HOST") String host) {
return new RedisCache<>(host, port, password, expiration, database, String.class, String.class);
}
@Bean
public RedisCache<String, Schema> schemaCache() {
public RedisCache<String, Schema> schemaCache(@Named("REDIS_HOST") String host) {
return new RedisCache<>(host, port, password, expiration, database, String.class, Schema.class);
}
}
......@@ -64,9 +78,6 @@ public class RedisConfig {
@ConditionalOnExpression(value = "'${cache.provider}' == 'redis' && !'${redis.ssl.enabled:true}'")
static class NoSslConfig {
@Value("${redis.host}")
private String host;
@Value("${redis.port}")
private int port;
......@@ -77,17 +88,17 @@ public class RedisConfig {
private int expiration;
@Bean
public RedisCache<String, Groups> groupCache() {
public RedisCache<String, Groups> groupCache(@Named("REDIS_HOST") String host) {
return new RedisCache<>(host, port, expiration, database, String.class, Groups.class);
}
@Bean("legalTagCache")
public RedisCache<String, String> legalTagCache() {
public RedisCache<String, String> legalTagCache(@Named("REDIS_HOST") String host) {
return new RedisCache<>(host, port, expiration, database, String.class, String.class);
}
@Bean
public RedisCache<String, Schema> schemaCache() {
public RedisCache<String, Schema> schemaCache(@Named("REDIS_HOST") String host) {
return new RedisCache<>(host, port, expiration, database, String.class, Schema.class);
}
}
......
......@@ -74,7 +74,7 @@ schema.cache.expiration=5
legalTag.cache.expiration=60
vm.cache.maxSize=1000
# Redis
redis.host=${redis_host}
redis.host=
redis.port=6380
redis.database=${REDIS_DATABASE}
redis.expiration=3600
......
Supports Markdown
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