Ordered Support for S3,Credhub, Redis profiles. Fixes gm-1980 (#1982)

Co-authored-by: knv <srinivaskatta@freo.money>
This commit is contained in:
knv srinivas
2021-10-20 20:55:31 +05:30
committed by GitHub
parent 998a4cadf2
commit ee35eac3fa
4 changed files with 28 additions and 3 deletions

View File

@@ -47,6 +47,7 @@ public class AwsS3EnvironmentRepositoryFactory
AwsS3EnvironmentRepository repository = new AwsS3EnvironmentRepository(client,
environmentProperties.getBucket(), server);
repository.setOrder(environmentProperties.getOrder());
return repository;
}

View File

@@ -21,6 +21,7 @@ import java.util.Map;
import org.springframework.cloud.config.environment.Environment;
import org.springframework.cloud.config.environment.PropertySource;
import org.springframework.core.Ordered;
import org.springframework.credhub.core.CredHubOperations;
import org.springframework.credhub.support.CredentialDetails;
import org.springframework.credhub.support.SimpleCredentialName;
@@ -31,8 +32,9 @@ import static java.util.stream.Collectors.toMap;
/**
* @author Alberto C. Ríos
* @author KNV Srinivas
*/
public class CredhubEnvironmentRepository implements EnvironmentRepository {
public class CredhubEnvironmentRepository implements EnvironmentRepository, Ordered {
private CredHubOperations credHubOperations;
@@ -42,6 +44,8 @@ public class CredhubEnvironmentRepository implements EnvironmentRepository {
private static final String DEFAULT_APPLICATION = "application";
private int order = Ordered.LOWEST_PRECEDENCE;
public CredhubEnvironmentRepository(CredHubOperations credHubOperations) {
this.credHubOperations = credHubOperations;
}
@@ -97,4 +101,12 @@ public class CredhubEnvironmentRepository implements EnvironmentRepository {
.collect(toMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> b));
}
@Override
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
}

View File

@@ -20,6 +20,7 @@ import org.springframework.credhub.core.CredHubOperations;
/**
* @author Alberto C. Ríos
* @author KNV Srinivas
*/
public class CredhubEnvironmentRepositoryFactory
implements EnvironmentRepositoryFactory<CredhubEnvironmentRepository, CredhubEnvironmentProperties> {
@@ -32,7 +33,9 @@ public class CredhubEnvironmentRepositoryFactory
@Override
public CredhubEnvironmentRepository build(CredhubEnvironmentProperties environmentProperties) {
return new CredhubEnvironmentRepository(this.credhubOperations);
CredhubEnvironmentRepository repository = new CredhubEnvironmentRepository(this.credhubOperations);
repository.setOrder(environmentProperties.getOrder());
return repository;
}
}

View File

@@ -24,21 +24,26 @@ import java.util.Map;
import org.springframework.cloud.config.environment.Environment;
import org.springframework.cloud.config.environment.PropertySource;
import org.springframework.core.Ordered;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.util.StringUtils;
/**
* @author Piotr Mińkowski
* @author KNV Srinivas
*/
public class RedisEnvironmentRepository implements EnvironmentRepository {
public class RedisEnvironmentRepository implements EnvironmentRepository, Ordered {
private final StringRedisTemplate redis;
private final RedisEnvironmentProperties properties;
private final int order;
public RedisEnvironmentRepository(StringRedisTemplate redis, RedisEnvironmentProperties properties) {
this.redis = redis;
this.properties = properties;
this.order = properties.getOrder();
}
@Override
@@ -63,4 +68,8 @@ public class RedisEnvironmentRepository implements EnvironmentRepository {
return keys;
}
@Override
public int getOrder() {
return order;
}
}