@@ -132,30 +132,37 @@ public class AwsS3EnvironmentRepository implements EnvironmentRepository, Ordere
|
||||
|
||||
private S3ConfigFile getS3ConfigFile(S3ObjectIdBuilder s3ObjectIdBuilder, String keyPrefix) {
|
||||
try {
|
||||
final S3Object properties = s3Client
|
||||
.getObject(new GetObjectRequest(s3ObjectIdBuilder.withKey(keyPrefix + ".properties").build()));
|
||||
final S3Object properties = getObject(s3ObjectIdBuilder, keyPrefix + ".properties");
|
||||
return new PropertyS3ConfigFile(properties.getObjectMetadata().getVersionId(),
|
||||
properties.getObjectContent());
|
||||
}
|
||||
catch (Exception eProperties) {
|
||||
try {
|
||||
final S3Object yaml = s3Client
|
||||
.getObject(new GetObjectRequest(s3ObjectIdBuilder.withKey(keyPrefix + ".yml").build()));
|
||||
final S3Object yaml = getObject(s3ObjectIdBuilder, keyPrefix + ".yaml");
|
||||
return new YamlS3ConfigFile(yaml.getObjectMetadata().getVersionId(), yaml.getObjectContent());
|
||||
}
|
||||
catch (Exception eYaml) {
|
||||
try {
|
||||
final S3Object json = s3Client
|
||||
.getObject(new GetObjectRequest(s3ObjectIdBuilder.withKey(keyPrefix + ".json").build()));
|
||||
return new JsonS3ConfigFile(json.getObjectMetadata().getVersionId(), json.getObjectContent());
|
||||
final S3Object json = getObject(s3ObjectIdBuilder, keyPrefix + ".yml");
|
||||
return new YamlS3ConfigFile(json.getObjectMetadata().getVersionId(), json.getObjectContent());
|
||||
}
|
||||
catch (Exception eJson) {
|
||||
return null;
|
||||
catch (Exception eYml) {
|
||||
try {
|
||||
final S3Object json = getObject(s3ObjectIdBuilder, keyPrefix + ".json");
|
||||
return new JsonS3ConfigFile(json.getObjectMetadata().getVersionId(), json.getObjectContent());
|
||||
}
|
||||
catch (Exception eJson) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private S3Object getObject(S3ObjectIdBuilder s3ObjectIdBuilder, String key) throws Exception {
|
||||
return s3Client.getObject(new GetObjectRequest(s3ObjectIdBuilder.withKey(key).build()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locations getLocations(String application, String profiles, String label) {
|
||||
String baseLocation = AWS_S3_RESOURCE_SCHEME + bucketName + PATH_SEPARATOR + application;
|
||||
|
||||
@@ -113,6 +113,15 @@ public class AwsS3EnvironmentRepositoryTests {
|
||||
|
||||
@Test
|
||||
public void findYamlObject() throws UnsupportedEncodingException {
|
||||
setupS3("foo-bar.yaml", yamlContent);
|
||||
|
||||
final Environment env = envRepo.findOne("foo", "bar", null);
|
||||
|
||||
assertExpectedEnvironment(env, "foo", null, null, 1, "bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findYmlObject() throws UnsupportedEncodingException {
|
||||
setupS3("foo-bar.yml", yamlContent);
|
||||
|
||||
final Environment env = envRepo.findOne("foo", "bar", null);
|
||||
|
||||
Reference in New Issue
Block a user