mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix(lambda): omit ImageConfigResponse when an Image function has no image config (#7103)
This commit is contained in:
1 parent
0a4cd51acb
commit
246473acf5
2 files changed
+44
-4
No files matched your search
@@ -734,17 +734,22 @@ public class LambdaController {
|
||||
node.put("CodeSha256", fn.getCodeSha256() != null ? fn.getCodeSha256() : "");
|
||||
node.put("PackageType", fn.getPackageType());
|
||||
if (fn.getImageUri() != null) node.put("ImageUri", fn.getImageUri());
|
||||
if ("Image".equals(fn.getPackageType())) {
|
||||
boolean hasCommand = fn.getImageConfigCommand() != null && !fn.getImageConfigCommand().isEmpty();
|
||||
boolean hasEntryPoint = fn.getImageConfigEntryPoint() != null && !fn.getImageConfigEntryPoint().isEmpty();
|
||||
boolean hasWorkingDirectory = fn.getImageConfigWorkingDirectory() != null
|
||||
&& !fn.getImageConfigWorkingDirectory().isBlank();
|
||||
// AWS omits ImageConfigResponse when no override is set; an empty one reads as drift in Terraform.
|
||||
if ("Image".equals(fn.getPackageType()) && (hasCommand || hasEntryPoint || hasWorkingDirectory)) {
|
||||
ObjectNode imageConfig = node.putObject("ImageConfigResponse").putObject("ImageConfig");
|
||||
if (fn.getImageConfigCommand() != null && !fn.getImageConfigCommand().isEmpty()) {
|
||||
if (hasCommand) {
|
||||
ArrayNode cmdNode = imageConfig.putArray("Command");
|
||||
fn.getImageConfigCommand().forEach(cmdNode::add);
|
||||
}
|
||||
if (fn.getImageConfigEntryPoint() != null && !fn.getImageConfigEntryPoint().isEmpty()) {
|
||||
if (hasEntryPoint) {
|
||||
ArrayNode epNode = imageConfig.putArray("EntryPoint");
|
||||
fn.getImageConfigEntryPoint().forEach(epNode::add);
|
||||
}
|
||||
if (fn.getImageConfigWorkingDirectory() != null && !fn.getImageConfigWorkingDirectory().isBlank()) {
|
||||
if (hasWorkingDirectory) {
|
||||
imageConfig.put("WorkingDirectory", fn.getImageConfigWorkingDirectory());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -481,6 +481,41 @@ class LambdaIntegrationTest {
|
||||
.statusCode(204);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(24)
|
||||
void imageConfigResponseOnlyWhenImageConfigSet() {
|
||||
String create = """
|
||||
{
|
||||
"FunctionName": "%s",
|
||||
"PackageType": "Image",
|
||||
"Role": "arn:aws:iam::000000000000:role/lambda-role",
|
||||
"Code": {
|
||||
"ImageUri": "123456789012.dkr.ecr.us-east-1.amazonaws.com/my-repo:latest"
|
||||
}%s
|
||||
}
|
||||
""";
|
||||
given().contentType("application/json")
|
||||
.body(create.formatted("image-no-config-fn", ""))
|
||||
.when().post(BASE_PATH + "/functions")
|
||||
.then().statusCode(201);
|
||||
given().contentType("application/json")
|
||||
.body(create.formatted("image-cmd-fn", ", \"ImageConfig\": {\"Command\": [\"app.handler\"]}"))
|
||||
.when().post(BASE_PATH + "/functions")
|
||||
.then().statusCode(201);
|
||||
|
||||
given().when().get(BASE_PATH + "/functions/image-no-config-fn/configuration")
|
||||
.then().statusCode(200)
|
||||
.body("PackageType", equalTo("Image"))
|
||||
.body("$", not(hasKey("ImageConfigResponse")));
|
||||
given().when().get(BASE_PATH + "/functions/image-cmd-fn/configuration")
|
||||
.then().statusCode(200)
|
||||
.body("ImageConfigResponse.ImageConfig.Command", contains("app.handler"))
|
||||
.body("ImageConfigResponse.ImageConfig", not(hasKey("EntryPoint")));
|
||||
|
||||
given().delete(BASE_PATH + "/functions/image-no-config-fn");
|
||||
given().delete(BASE_PATH + "/functions/image-cmd-fn");
|
||||
}
|
||||
|
||||
// ──────────────────────────── Invoke payload size limits ────────────────────────────
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user