mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(rds): restore Terraform RDS and RabbitMQ compatibility (#1951)
* fix(rds): support dbi resource id filter * fix(mq): omit RabbitMQ users from broker response
This commit is contained in:
1 parent
a5daab6fb7
commit
ea1231b8b4
6 files changed
+75
-4
No files matched your search
@@ -90,7 +90,6 @@ public class AmazonMqController {
|
||||
body.put("autoMinorVersionUpgrade", b.isAutoMinorVersionUpgrade());
|
||||
body.put("created", b.getCreated());
|
||||
body.put("brokerInstances", b.getBrokerInstances());
|
||||
body.put("users", b.getUsers());
|
||||
body.put("tags", b.getTags());
|
||||
return body;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,15 @@ public class RdsQueryHandler {
|
||||
filterId = extractRdsFilterValue(params, "db-instance-id");
|
||||
}
|
||||
try {
|
||||
Collection<DbInstance> result = service.listDbInstances(filterId);
|
||||
Collection<DbInstance> result;
|
||||
if (filterId != null && !filterId.isBlank()) {
|
||||
result = service.listDbInstances(filterId);
|
||||
} else {
|
||||
List<String> resourceIds = extractRdsFilterValues(params, "dbi-resource-id");
|
||||
result = resourceIds.isEmpty()
|
||||
? service.listDbInstances(null)
|
||||
: service.listDbInstancesByDbiResourceIds(resourceIds);
|
||||
}
|
||||
// AWS parity: the DBInstanceIdentifier PARAMETER faults with
|
||||
// DBInstanceNotFound when no instance matches, while the
|
||||
// db-instance-id Filters form returns an empty list.
|
||||
@@ -925,16 +933,35 @@ public class RdsQueryHandler {
|
||||
* Returns null if no matching filter is present.
|
||||
*/
|
||||
private static String extractRdsFilterValue(MultivaluedMap<String, String> params, String filterName) {
|
||||
List<String> values = extractRdsFilterValues(params, filterName);
|
||||
return values.isEmpty() ? null : values.getFirst();
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts all values for a named RDS filter. Values within one filter use
|
||||
* AWS OR semantics and are encoded as {@code Values.Value.N}.
|
||||
*/
|
||||
private static List<String> extractRdsFilterValues(MultivaluedMap<String, String> params, String filterName) {
|
||||
for (int i = 1; ; i++) {
|
||||
String name = params.getFirst("Filters.Filter." + i + ".Name");
|
||||
if (name == null) {
|
||||
break;
|
||||
}
|
||||
if (filterName.equals(name)) {
|
||||
return params.getFirst("Filters.Filter." + i + ".Values.Value.1");
|
||||
java.util.ArrayList<String> values = new java.util.ArrayList<>();
|
||||
for (int valueIndex = 1; ; valueIndex++) {
|
||||
String value = params.getFirst("Filters.Filter." + i + ".Values.Value." + valueIndex);
|
||||
if (value == null) {
|
||||
break;
|
||||
}
|
||||
if (!value.isBlank()) {
|
||||
values.add(value);
|
||||
}
|
||||
}
|
||||
return List.copyOf(values);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return List.of();
|
||||
}
|
||||
|
||||
private static List<String> memberList(MultivaluedMap<String, String> params, String baseName) {
|
||||
|
||||
@@ -545,6 +545,15 @@ public class RdsService implements Resettable {
|
||||
return instances.scan(k -> true);
|
||||
}
|
||||
|
||||
public Collection<DbInstance> listDbInstancesByDbiResourceIds(Collection<String> resourceIds) {
|
||||
if (resourceIds == null || resourceIds.isEmpty()) {
|
||||
return instances.scan(k -> true);
|
||||
}
|
||||
return instances.scan(k -> true).stream()
|
||||
.filter(instance -> resourceIds.contains(instance.getDbiResourceId()))
|
||||
.toList();
|
||||
}
|
||||
|
||||
public DbInstance modifyDbInstance(String id, String newPassword, Boolean iamEnabled,
|
||||
String dbSubnetGroupName) {
|
||||
return modifyDbInstance(id, newPassword, iamEnabled, dbSubnetGroupName, null);
|
||||
|
||||
Reference in new issue
Block a user