mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
Feat/lambda image config working directory (#673)
* feat(lambda): support ImageConfig.WorkingDirectory override Propagate WorkingDirectory from the Lambda ImageConfig through the full stack so container images that rely on a specific WORKDIR can be invoked correctly, matching real AWS behavior. - LambdaFunction: add imageConfigWorkingDirectory field + getter/setter - LambdaService: parse WorkingDirectory on CreateFunction and UpdateFunctionConfiguration - ContainerSpec: add workingDir record component - ContainerBuilder: add withWorkingDir() fluent method - ContainerLifecycleManager: pass workingDir to Docker via withWorkingDir() - ContainerLauncher: apply workingDir when building the container spec - LambdaController: serialize WorkingDirectory in ImageConfigResponse * test(lambda): add tests for ImageConfig.WorkingDirectory Unit tests (LambdaImageConfigTest): - CreateFunction stores WorkingDirectory alongside Command/EntryPoint - createFunction with all three fields together - updateFunctionConfiguration updates and clears WorkingDirectory - ContainerLauncher passes workingDir to ContainerSpec Compat tests across all SDKs: - awscli (lambda.bats): create/get/update WorkingDirectory round-trip - Java SDK (LambdaFunctionConfigTest): ImageConfig.WorkingDirectory round-trip - Python (test_lambda_function_config.py): TestImageConfigWorkingDirectory class - Node (lambda.test.ts): create/update WorkingDirectory assertions - Go (lambda_test.go): TestLambdaImageConfigWorkingDirectory subtests - Rust (lambda_test.rs): full create/get/update round-trip
This commit is contained in:
14 files changed
+494
-5
No files matched your search
@@ -96,12 +96,41 @@ class LambdaImageConfigTest {
|
||||
assertEquals(List.of("/entry.sh"), fn.getImageConfigEntryPoint());
|
||||
}
|
||||
|
||||
@Test
|
||||
void storesImageConfigWorkingDirectory() {
|
||||
Map<String, Object> req = imageRequest("fn-wd");
|
||||
req.put("ImageConfig", Map.of("WorkingDirectory", "/app"));
|
||||
|
||||
LambdaFunction fn = service.createFunction(REGION, req);
|
||||
|
||||
assertEquals("/app", fn.getImageConfigWorkingDirectory());
|
||||
assertNull(fn.getImageConfigCommand());
|
||||
assertNull(fn.getImageConfigEntryPoint());
|
||||
}
|
||||
|
||||
@Test
|
||||
void storesAllThreeImageConfigFields() {
|
||||
Map<String, Object> req = imageRequest("fn-all");
|
||||
req.put("ImageConfig", Map.of(
|
||||
"Command", List.of("app.handler"),
|
||||
"EntryPoint", List.of("/entry.sh"),
|
||||
"WorkingDirectory", "/workspace"
|
||||
));
|
||||
|
||||
LambdaFunction fn = service.createFunction(REGION, req);
|
||||
|
||||
assertEquals(List.of("app.handler"), fn.getImageConfigCommand());
|
||||
assertEquals(List.of("/entry.sh"), fn.getImageConfigEntryPoint());
|
||||
assertEquals("/workspace", fn.getImageConfigWorkingDirectory());
|
||||
}
|
||||
|
||||
@Test
|
||||
void noImageConfigLeavesFieldsNull() {
|
||||
LambdaFunction fn = service.createFunction(REGION, imageRequest("fn-none"));
|
||||
|
||||
assertNull(fn.getImageConfigCommand());
|
||||
assertNull(fn.getImageConfigEntryPoint());
|
||||
assertNull(fn.getImageConfigWorkingDirectory());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,6 +175,32 @@ class LambdaImageConfigTest {
|
||||
|
||||
assertTrue(fn.getImageConfigCommand() == null || fn.getImageConfigCommand().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void updatesImageConfigWorkingDirectory() {
|
||||
service.createFunction(REGION, imageRequest("fn-upd-wd"));
|
||||
|
||||
Map<String, Object> update = new HashMap<>();
|
||||
update.put("ImageConfig", Map.of("WorkingDirectory", "/updated"));
|
||||
LambdaFunction fn = service.updateFunctionConfiguration(REGION, "fn-upd-wd", update);
|
||||
|
||||
assertEquals("/updated", fn.getImageConfigWorkingDirectory());
|
||||
}
|
||||
|
||||
@Test
|
||||
void clearsWorkingDirectoryWhenNullValueProvided() {
|
||||
Map<String, Object> req = imageRequest("fn-clear-wd");
|
||||
req.put("ImageConfig", Map.of("WorkingDirectory", "/initial"));
|
||||
service.createFunction(REGION, req);
|
||||
|
||||
Map<String, Object> update = new HashMap<>();
|
||||
Map<String, Object> imageConfig = new HashMap<>();
|
||||
imageConfig.put("WorkingDirectory", null);
|
||||
update.put("ImageConfig", imageConfig);
|
||||
LambdaFunction fn = service.updateFunctionConfiguration(REGION, "fn-clear-wd", update);
|
||||
|
||||
assertNull(fn.getImageConfigWorkingDirectory());
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@@ -259,6 +314,31 @@ class LambdaImageConfigTest {
|
||||
assertNull(spec.entrypoint());
|
||||
}
|
||||
|
||||
@Test
|
||||
void usesImageConfigWorkingDirectoryForImageFunction() {
|
||||
LambdaFunction fn = imageFn("img-wd-fn");
|
||||
fn.setImageConfigWorkingDirectory("/app");
|
||||
|
||||
launcher.launch(fn);
|
||||
|
||||
ArgumentCaptor<ContainerSpec> specCaptor = ArgumentCaptor.forClass(ContainerSpec.class);
|
||||
verify(lifecycleManager).create(specCaptor.capture());
|
||||
|
||||
assertEquals("/app", specCaptor.getValue().workingDir());
|
||||
}
|
||||
|
||||
@Test
|
||||
void doesNotSetWorkingDirWhenNotConfigured() {
|
||||
LambdaFunction fn = imageFn("img-no-wd-fn");
|
||||
|
||||
launcher.launch(fn);
|
||||
|
||||
ArgumentCaptor<ContainerSpec> specCaptor = ArgumentCaptor.forClass(ContainerSpec.class);
|
||||
verify(lifecycleManager).create(specCaptor.capture());
|
||||
|
||||
assertNull(specCaptor.getValue().workingDir(), "workingDir must be null when not configured");
|
||||
}
|
||||
|
||||
@Test
|
||||
void zipFunctionStillUsesHandlerAsCmd() throws Exception {
|
||||
LambdaFunction fn = new LambdaFunction();
|
||||
|
||||
Reference in new issue
Block a user