fic: env var for base lambda overwrite (#189)

* feat: AWS ECR Override for Lambda images

To support users who wish to pull AWS Lambda images from private registries (eg Artifactory hosted proxy repos), a new config option / environment variable is introduced.

resolves #165
This commit is contained in:
John Coyne authored and GitHub committed 2026-04-03 08:25:57 -05:00
1 parent 835f8c6ff4
commit 52d53f9a69
4 files changed
+88 -19

No files matched your search

@@ -1,15 +1,23 @@
package io.github.hectorvent.floci.services.lambda.launcher;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.core.common.AwsException;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
class ImageResolverTest {
private final ImageResolver resolver = new ImageResolver();
private final EmulatorConfig config = mock(EmulatorConfig.class);
private final ImageResolver resolver;
ImageResolverTest() {
when(config.ecrBaseUri()).thenReturn("public.ecr.aws");
this.resolver = new ImageResolver(config);
}
@ParameterizedTest
@CsvSource({
@@ -33,6 +41,56 @@ class ImageResolverTest {
assertEquals(expectedImage, resolver.resolve(runtime));
}
@ParameterizedTest
@CsvSource({
"java21, my.custom.host/lambda/java:21",
"java17, my.custom.host/lambda/java:17",
"java11, my.custom.host/lambda/java:11",
"python3.13, my.custom.host/lambda/python:3.13",
"python3.12, my.custom.host/lambda/python:3.12",
"python3.11, my.custom.host/lambda/python:3.11",
"python3.10, my.custom.host/lambda/python:3.10",
"python3.9, my.custom.host/lambda/python:3.9",
"nodejs22.x, my.custom.host/lambda/nodejs:22",
"nodejs20.x, my.custom.host/lambda/nodejs:20",
"nodejs18.x, my.custom.host/lambda/nodejs:18",
"ruby3.3, my.custom.host/lambda/ruby:3.3",
"ruby3.2, my.custom.host/lambda/ruby:3.2",
"provided.al2023, my.custom.host/lambda/provided:al2023",
"provided.al2, my.custom.host/lambda/provided:al2"
})
void resolvesKnownRuntimesWithHostOverride(String runtime, String expectedImage) {
EmulatorConfig customConfig = mock(EmulatorConfig.class);
when(customConfig.ecrBaseUri()).thenReturn("my.custom.host");
ImageResolver customResolver = new ImageResolver(customConfig);
assertEquals(expectedImage, customResolver.resolve(runtime));
}
@ParameterizedTest
@CsvSource({
"java21, my.custom.host/path/lambda/java:21",
"java17, my.custom.host/path/lambda/java:17",
"java11, my.custom.host/path/lambda/java:11",
"python3.13, my.custom.host/path/lambda/python:3.13",
"python3.12, my.custom.host/path/lambda/python:3.12",
"python3.11, my.custom.host/path/lambda/python:3.11",
"python3.10, my.custom.host/path/lambda/python:3.10",
"python3.9, my.custom.host/path/lambda/python:3.9",
"nodejs22.x, my.custom.host/path/lambda/nodejs:22",
"nodejs20.x, my.custom.host/path/lambda/nodejs:20",
"nodejs18.x, my.custom.host/path/lambda/nodejs:18",
"ruby3.3, my.custom.host/path/lambda/ruby:3.3",
"ruby3.2, my.custom.host/path/lambda/ruby:3.2",
"provided.al2023, my.custom.host/path/lambda/provided:al2023",
"provided.al2, my.custom.host/path/lambda/provided:al2"
})
void resolvesKnownRuntimesWithHostAndPathOverride(String runtime, String expectedImage) {
EmulatorConfig customConfig = mock(EmulatorConfig.class);
when(customConfig.ecrBaseUri()).thenReturn("my.custom.host/path");
ImageResolver customResolver = new ImageResolver(customConfig);
assertEquals(expectedImage, customResolver.resolve(runtime));
}
@Test
void passesThroughCustomImageWithSlash() {
String customImage = "123456789.dkr.ecr.us-east-1.amazonaws.com/my-function:latest";