mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
fix: issues 226 227 (#257)
* feat(eventbridge): add ListTagsForResource support * feat(lambda): add GetFunctionCodeSigningConfig endpoint
This commit is contained in:
1 parent
18bee5b278
commit
81f1a01c39
5 files changed
+270
No files matched your search
@@ -57,6 +57,7 @@ public class EventBridgeHandler {
|
||||
case "RemoveTargets" -> handleRemoveTargets(request, region);
|
||||
case "ListTargetsByRule" -> handleListTargetsByRule(request, region);
|
||||
case "PutEvents" -> handlePutEvents(request, region);
|
||||
case "ListTagsForResource" -> handleListTagsForResource(request, region);
|
||||
default -> Response.status(400)
|
||||
.entity(new AwsErrorResponse("UnsupportedOperation", "Operation " + action + " is not supported."))
|
||||
.build();
|
||||
@@ -264,6 +265,23 @@ public class EventBridgeHandler {
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
private Response handleListTagsForResource(JsonNode request, String region) {
|
||||
String resourceArn = request.path("ResourceARN").asText(null);
|
||||
if (resourceArn == null || resourceArn.isBlank()) {
|
||||
throw new AwsException("InvalidParameterValue", "ResourceARN is required.", 400);
|
||||
}
|
||||
Map<String, String> tags = eventBridgeService.listTagsForResource(resourceArn, region);
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
ArrayNode tagsArray = response.putArray("Tags");
|
||||
tags.forEach((key, value) -> {
|
||||
ObjectNode tagNode = objectMapper.createObjectNode();
|
||||
tagNode.put("Key", key);
|
||||
tagNode.put("Value", value);
|
||||
tagsArray.add(tagNode);
|
||||
});
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
// ──────────────────────────── Helpers ────────────────────────────
|
||||
|
||||
private ObjectNode buildBusNode(EventBus bus) {
|
||||
|
||||
@@ -305,6 +305,40 @@ public class EventBridgeService {
|
||||
return targetStore.get(key).orElse(List.of());
|
||||
}
|
||||
|
||||
// ──────────────────────────── Tags ────────────────────────────
|
||||
|
||||
public Map<String, String> listTagsForResource(String resourceArn, String region) {
|
||||
// Check if it's an event bus ARN (contains "event-bus/")
|
||||
if (resourceArn.contains("event-bus/")) {
|
||||
String busName = resourceArn.substring(resourceArn.lastIndexOf("event-bus/") + "event-bus/".length());
|
||||
String key = busKey(region, busName);
|
||||
return busStore.get(key)
|
||||
.map(EventBus::getTags)
|
||||
.orElse(Map.of());
|
||||
}
|
||||
// Check if it's a rule ARN (contains "rule/")
|
||||
if (resourceArn.contains("rule/")) {
|
||||
String afterRule = resourceArn.substring(resourceArn.lastIndexOf("rule/") + "rule/".length());
|
||||
String busName;
|
||||
String ruleName;
|
||||
if (afterRule.contains("/")) {
|
||||
// Custom bus: rule/{busName}/{ruleName}
|
||||
int slashIdx = afterRule.indexOf('/');
|
||||
busName = afterRule.substring(0, slashIdx);
|
||||
ruleName = afterRule.substring(slashIdx + 1);
|
||||
} else {
|
||||
// Default bus: rule/{ruleName}
|
||||
busName = "default";
|
||||
ruleName = afterRule;
|
||||
}
|
||||
String key = ruleKey(region, busName, ruleName);
|
||||
return ruleStore.get(key)
|
||||
.map(Rule::getTags)
|
||||
.orElse(Map.of());
|
||||
}
|
||||
return Map.of();
|
||||
}
|
||||
|
||||
// ──────────────────────────── PutEvents ────────────────────────────
|
||||
|
||||
public record PutEventsResult(int failedCount, List<Map<String, String>> entries) {}
|
||||
|
||||
@@ -148,6 +148,22 @@ public class LambdaController {
|
||||
return Response.noContent().build();
|
||||
}
|
||||
|
||||
// ──────────────────────────── GetFunctionCodeSigningConfig ────────────────────────────
|
||||
|
||||
@GET
|
||||
@Path("/functions/{functionName}/code-signing-config")
|
||||
public Response getFunctionCodeSigningConfig(@Context HttpHeaders headers,
|
||||
@PathParam("functionName") String functionName) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
// Verify the function exists
|
||||
lambdaService.getFunction(region, functionName);
|
||||
// Return empty code signing config — floci does not enforce code signing
|
||||
ObjectNode root = objectMapper.createObjectNode();
|
||||
root.put("CodeSigningConfigArn", "");
|
||||
root.put("FunctionName", functionName);
|
||||
return Response.ok(root).build();
|
||||
}
|
||||
|
||||
// ──────────────────────────── Invoke ────────────────────────────
|
||||
|
||||
@POST
|
||||
|
||||
Reference in new issue
Block a user