mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(ecr): support image scanning configuration updates (#4928)
* fix(ecr): support image scanning configuration updates * fix(ecr): validate scanning configuration booleans * fix(ecr): accept null scan-on-push values * docs(ecr): list the image scanning configuration actions Add PutImageScanningConfiguration and BatchGetRepositoryScanningConfiguration to the Supported Actions table. The table is not generated, so the docs check does not catch a missing row.
This commit is contained in:
1 parent
0260a42549
commit
543f01618f
5 files changed
+125
-11
No files matched your search
@@ -50,6 +50,7 @@ public class EcrJsonHandler {
|
||||
case "ValidatePullThroughCacheRule" -> handleValidatePullThroughCacheRule(request, region);
|
||||
case "DeletePullThroughCacheRule" -> handleDeletePullThroughCacheRule(request, region);
|
||||
case "DescribeRepositories" -> handleDescribeRepositories(request, region);
|
||||
case "PutImageScanningConfiguration" -> handlePutImageScanningConfiguration(request, region);
|
||||
case "BatchGetRepositoryScanningConfiguration" ->
|
||||
handleBatchGetRepositoryScanningConfiguration(request, region);
|
||||
case "DeleteRepository" -> handleDeleteRepository(request, region);
|
||||
@@ -226,6 +227,35 @@ public class EcrJsonHandler {
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
private Response handlePutImageScanningConfiguration(JsonNode request, String region) {
|
||||
JsonNode scanningConfiguration = request.path("imageScanningConfiguration");
|
||||
if (!scanningConfiguration.isObject()) {
|
||||
throw new AwsException("InvalidParameterException",
|
||||
"imageScanningConfiguration is required", 400);
|
||||
}
|
||||
|
||||
String repositoryName = request.path("repositoryName").asText(null);
|
||||
String registryId = request.path("registryId").asText(null);
|
||||
JsonNode scanOnPushNode = scanningConfiguration.path("scanOnPush");
|
||||
if (!scanOnPushNode.isMissingNode()
|
||||
&& !scanOnPushNode.isNull()
|
||||
&& !scanOnPushNode.isBoolean()) {
|
||||
throw new AwsException("InvalidParameterException",
|
||||
"scanOnPush must be a boolean", 400);
|
||||
}
|
||||
boolean scanOnPush = scanOnPushNode.asBoolean(false);
|
||||
Repository updated = service.putImageScanningConfiguration(
|
||||
repositoryName, registryId, scanOnPush, region);
|
||||
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
response.put("registryId", updated.getRegistryId());
|
||||
response.put("repositoryName", updated.getRepositoryName());
|
||||
ObjectNode imageScanningConfiguration = objectMapper.createObjectNode();
|
||||
imageScanningConfiguration.put("scanOnPush", updated.isScanOnPush());
|
||||
response.set("imageScanningConfiguration", imageScanningConfiguration);
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
private Response handleDeleteRepository(JsonNode request, String region) {
|
||||
String repositoryName = request.path("repositoryName").asText(null);
|
||||
String registryId = request.path("registryId").asText(null);
|
||||
|
||||
@@ -617,6 +617,14 @@ public class EcrService implements ResourceProvider {
|
||||
// Tag mutability + resource tags + policies (metadata round-trip)
|
||||
// ============================================================
|
||||
|
||||
public Repository putImageScanningConfiguration(String repositoryName, String registryId,
|
||||
boolean scanOnPush, String region) {
|
||||
Repository repo = requireRepo(repositoryName, registryId, region);
|
||||
repo.setScanOnPush(scanOnPush);
|
||||
repoStore.put(key(region, repo.getRegistryId(), repositoryName), repo);
|
||||
return repo;
|
||||
}
|
||||
|
||||
public Repository putImageTagMutability(String repositoryName, String registryId,
|
||||
String mutability, String region) {
|
||||
if (mutability == null
|
||||
|
||||
Reference in new issue
Block a user