Merge branch '3.1.x'

This commit is contained in:
Ryan Baxter
2022-09-15 19:34:35 -04:00
2 changed files with 27 additions and 10 deletions

View File

@@ -130,29 +130,37 @@ public class AwsS3EnvironmentRepository implements EnvironmentRepository, Ordere
private S3ConfigFile getS3ConfigFile(String keyPrefix) {
try {
final ResponseInputStream<GetObjectResponse> responseInputStream = s3Client
.getObject(GetObjectRequest.builder().bucket(bucketName).key(keyPrefix + ".properties").build());
final ResponseInputStream<GetObjectResponse> responseInputStream = getObject(keyPrefix + ".properties");
return new PropertyS3ConfigFile(responseInputStream.response().versionId(), responseInputStream);
}
catch (Exception eProperties) {
try {
final ResponseInputStream<GetObjectResponse> responseInputStream = s3Client
.getObject(GetObjectRequest.builder().bucket(bucketName).key(keyPrefix + ".yml").build());
final ResponseInputStream<GetObjectResponse> responseInputStream = getObject(keyPrefix + ".yml");
return new YamlS3ConfigFile(responseInputStream.response().versionId(), responseInputStream);
}
catch (Exception eYaml) {
catch (Exception eYml) {
try {
final ResponseInputStream<GetObjectResponse> responseInputStream = s3Client
.getObject(GetObjectRequest.builder().bucket(bucketName).key(keyPrefix + ".json").build());
return new JsonS3ConfigFile(responseInputStream.response().versionId(), responseInputStream);
final ResponseInputStream<GetObjectResponse> responseInputStream = getObject(keyPrefix + ".yaml");
return new YamlS3ConfigFile(responseInputStream.response().versionId(), responseInputStream);
}
catch (Exception eJson) {
return null;
catch (Exception eYaml) {
try {
final ResponseInputStream<GetObjectResponse> responseInputStream = getObject(
keyPrefix + ".json");
return new JsonS3ConfigFile(responseInputStream.response().versionId(), responseInputStream);
}
catch (Exception eJson) {
return null;
}
}
}
}
}
private ResponseInputStream<GetObjectResponse> getObject(String key) throws Exception {
return s3Client.getObject(GetObjectRequest.builder().bucket(bucketName).key(key).build());
}
@Override
public Locations getLocations(String application, String profiles, String label) {
String baseLocation = AWS_S3_RESOURCE_SCHEME + bucketName + PATH_SEPARATOR + application;

View File

@@ -115,6 +115,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);