fix(lambda): replace the fabric8 kubernetes client with a plain REST client (#2919)

* fix(lambda): replace the fabric8 kubernetes client with a plain REST client

quarkus-kubernetes-client was an always-on dependency, so the fabric8 client
and its generated Kubernetes model classes were reachable in every native
image regardless of whether floci.services.lambda.executor was ever set to
kubernetes. That was the single largest contributor to a ~20% native image
size increase last month (issue #2914).

The kubernetes executor only ever needs a handful of plain REST calls
(create/get/list/delete pods, create-or-update a ConfigMap, stream logs)
against a plain JSON HTTPS API, the same shape Floci already talks to AWS
in without an SDK. KubernetesApiClient replaces the fabric8 client with the
JDK HttpClient (as FlinkRestClient already does for another container
orchestrator's REST API), so the dependency is gone entirely rather than
merely unused: it no longer appears anywhere in the packaged application,
native or JVM.

Connection resolution mirrors kubectl's for the common cases: in-cluster
service account (token re-read per call since projected tokens rotate, CA
loaded once), or a kubeconfig's current-context with a static bearer token
or client-certificate/client-key (PKCS#8) credential. exec/auth-provider
credential plugins (e.g. aws eks get-token) are not supported and fail
with a clear error naming the limitation.

LambdaPodSpecFactory now builds the pod manifest as a plain JSON tree
instead of fabric8 builders. Tests keep using fabric8's kubernetes-server-mock
as a fake API server (test-scope only, so it never reaches the shipped
artifact) and point KubernetesApiClient at it over HTTP(S) instead of
constructing a fabric8 client directly.

* fix(lambda): support insecure-skip-tls-verify and drop stale test devservices config

kubeconfig's insecure-skip-tls-verify (the common kind/minikube dev-cluster
case) fell through to the default trust store and failed with a generic
PKIX error instead of a named limitation like every other unsupported
kubeconfig case. Honor it: skip both chain and hostname validation,
matching kubectl. Verified against a real self-signed HTTPS server, both
with and without the flag, so a regression here fails loudly.

Also drops src/test/resources/application.yml's leftover
quarkus.kubernetes-client.devservices block: with the extension gone from
pom.xml that key is unrecognized config pointing at a dependency that no
longer exists.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-09-02 17:40:21 -05:00
1 parent 671628b525
commit 97ce09f22a
11 files changed
+1002 -269

No files matched your search

@@ -0,0 +1,121 @@
package io.github.hectorvent.floci.services.lambda.launcher.kubernetes;
import com.sun.net.httpserver.HttpsConfigurator;
import com.sun.net.httpserver.HttpsServer;
import io.github.hectorvent.floci.services.acm.CertificateGenerator;
import io.github.hectorvent.floci.services.acm.model.KeyAlgorithm;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import java.net.InetSocketAddress;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.KeyStore;
import java.security.Security;
import java.security.cert.Certificate;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/**
* Verifies kubeconfig's {@code insecure-skip-tls-verify} against a real self-signed HTTPS
* server, not just that the flag parses: without it, a self-signed server cert must still fail
* the handshake, or the flag would silently do nothing.
*/
class KubernetesApiClientKubeconfigTest {
private HttpsServer server;
@BeforeAll
static void registerBouncyCastle() {
if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) {
Security.addProvider(new BouncyCastleProvider());
}
}
@AfterEach
void tearDown() {
if (server != null) {
server.stop(0);
}
}
@Test
void insecureSkipTlsVerifyTrustsASelfSignedServerCert(@TempDir Path tempDir) throws Exception {
startSelfSignedServer();
var kubeconfig = writeKubeconfig(tempDir, true);
var client = new KubernetesApiClient();
client.initializeFromKubeconfigForTest(kubeconfig);
assertThat(client.getPod("default", "whatever")).isEmpty();
}
@Test
void withoutInsecureSkipTlsVerifyASelfSignedServerCertFailsTheHandshake(@TempDir Path tempDir) throws Exception {
startSelfSignedServer();
var kubeconfig = writeKubeconfig(tempDir, false);
var client = new KubernetesApiClient();
client.initializeFromKubeconfigForTest(kubeconfig);
assertThatThrownBy(() -> client.getPod("default", "whatever"))
.hasMessageContaining("Kubernetes API GET");
}
private void startSelfSignedServer() throws Exception {
var generator = new CertificateGenerator();
var generated = generator.generateSelfSignedCertificate(
"127.0.0.1", List.of("127.0.0.1"), KeyAlgorithm.RSA_2048);
var cert = generator.parseCertificate(generated.certificatePem());
var privateKey = generator.parsePrivateKey(generated.privateKeyPem());
var keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(null, null);
keyStore.setKeyEntry("server", privateKey, new char[0], new Certificate[]{cert});
var keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
keyManagerFactory.init(keyStore, new char[0]);
var sslContext = SSLContext.getInstance("TLS");
sslContext.init(keyManagerFactory.getKeyManagers(), null, null);
server = HttpsServer.create(new InetSocketAddress("127.0.0.1", 0), 0);
server.setHttpsConfigurator(new HttpsConfigurator(sslContext));
server.createContext("/", exchange -> {
exchange.sendResponseHeaders(404, -1);
exchange.close();
});
server.start();
}
private Path writeKubeconfig(Path tempDir, boolean insecureSkipTlsVerify) throws Exception {
var port = server.getAddress().getPort();
var config = """
apiVersion: v1
kind: Config
current-context: test
clusters:
- name: c
cluster:
server: https://127.0.0.1:%d
insecure-skip-tls-verify: %s
contexts:
- name: test
context:
cluster: c
user: u
users:
- name: u
user:
token: test-token
""".formatted(port, insecureSkipTlsVerify);
var path = tempDir.resolve("config");
Files.writeString(path, config);
return path;
}
}
@@ -20,6 +20,13 @@ import org.awaitility.Awaitility;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.net.URI;
import java.net.http.HttpClient;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.time.Duration;
import java.util.List;
import java.util.Map;
@@ -31,6 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.tuple;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyMap;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
@@ -42,10 +50,19 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/**
* {@code client} (the fabric8 mock server injected by {@code @EnableKubernetesMockClient}) plays
* two roles here: it is the fake HTTPS API server {@link #apiClient} talks to (over a trust-all
* {@link HttpClient}, since the mock's cert is self-signed and per-run), and it is used directly
* to seed pods and play the kubelet (setting phases) exactly as a real cluster would. Reading
* pods back through it after {@link #apiClient} creates them works because both talk to the same
* backing store; only the mock's transport is fabric8, never Floci's own code.
*/
@EnableKubernetesMockClient(crud = true)
class KubernetesPodLauncherTest {
KubernetesClient client;
private KubernetesApiClient apiClient;
private EmulatorConfig config;
private RuntimeApiServerFactory runtimeApiServerFactory;
private RuntimeApiServer runtimeApiServer;
@@ -100,11 +117,31 @@ class KubernetesPodLauncherTest {
lenient().when(logStreamer.logStreamName(anyString())).thenReturn("2026/07/25/[$LATEST]test");
s3Service = mock(S3Service.class);
launcher = new KubernetesPodLauncher(client, config, runtimeApiServerFactory, imageResolver,
apiClient = new KubernetesApiClient(
URI.create(client.getConfiguration().getMasterUrl()), trustAllHttpClient(), null);
launcher = new KubernetesPodLauncher(apiClient, config, runtimeApiServerFactory, imageResolver,
addressResolver, awsEnv, layerService, new LambdaPodSpecFactory(config),
logStreamer, s3Service);
}
/** The mock server's cert is self-signed and generated per run; trust it, not the JVM default. */
private static HttpClient trustAllHttpClient() {
try {
var trustAll = new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] chain, String authType) { }
public void checkServerTrusted(X509Certificate[] chain, String authType) { }
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
};
var context = SSLContext.getInstance("TLS");
context.init(null, new TrustManager[]{trustAll}, new SecureRandom());
return HttpClient.newBuilder().sslContext(context).build();
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
private LambdaFunction function() {
var fn = new LambdaFunction();
fn.setFunctionName("my-fn");
@@ -231,16 +268,9 @@ class KubernetesPodLauncherTest {
// the cleanup delete can never confirm the pod is gone. The pod could still reach
// Running later and poll AWS_LAMBDA_RUNTIME_API, so the port must stay reserved
// instead of going back to the pool for another environment.
var failingClient = spy(client);
doAnswer(invocation -> {
var failedPodExists = client.pods().inNamespace("default").list().getItems().stream()
.anyMatch(p -> p.getStatus() != null && "Failed".equals(p.getStatus().getPhase()));
if (failedPodExists) {
throw new RuntimeException("kube api down");
}
return invocation.callRealMethod();
}).when(failingClient).pods();
var failingLauncher = new KubernetesPodLauncher(failingClient, config,
var failingApiClient = spy(apiClient);
doThrow(new RuntimeException("kube api down")).when(failingApiClient).deletePod(anyString(), anyString());
var failingLauncher = new KubernetesPodLauncher(failingApiClient, config,
runtimeApiServerFactory, imageResolver, addressResolver, awsEnv, layerService,
new LambdaPodSpecFactory(config), logStreamer, s3Service);
markPodPhaseInBackground("floci-lambda-my-fn-", "Failed");
@@ -383,14 +413,14 @@ class KubernetesPodLauncherTest {
// First Kubernetes API access (the sweep's pod list) fails once.
var failedOnce = new AtomicBoolean();
var flakyClient = spy(client);
var flakyApiClient = spy(apiClient);
doAnswer(invocation -> {
if (failedOnce.compareAndSet(false, true)) {
throw new RuntimeException("kube api down");
}
return invocation.callRealMethod();
}).when(flakyClient).pods();
var retryingLauncher = new KubernetesPodLauncher(flakyClient, config,
}).when(flakyApiClient).listPods(anyString(), anyMap());
var retryingLauncher = new KubernetesPodLauncher(flakyApiClient, config,
runtimeApiServerFactory, imageResolver, addressResolver, awsEnv, layerService,
new LambdaPodSpecFactory(config), logStreamer, s3Service);
@@ -1,9 +1,6 @@
package io.github.hectorvent.floci.services.lambda.launcher.kubernetes;
import io.fabric8.kubernetes.api.model.EnvVar;
import io.fabric8.kubernetes.api.model.Pod;
import io.fabric8.kubernetes.api.model.Volume;
import io.fabric8.kubernetes.api.model.VolumeMount;
import com.fasterxml.jackson.databind.JsonNode;
import io.github.hectorvent.floci.config.EmulatorConfig;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -13,7 +10,10 @@ import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.assertj.core.api.Assertions.assertThat;
@@ -48,7 +48,7 @@ class LambdaPodSpecFactoryTest {
factory = new LambdaPodSpecFactory(config);
}
private Pod buildZipPod() {
private JsonNode buildZipPod() {
return factory.buildPod("floci-lambda-my-fn-abc12345", "my-fn",
"public.ecr.aws/lambda/python:3.12",
List.of("AWS_LAMBDA_RUNTIME_API=10.0.0.5:9200", "_HANDLER=index.handler"),
@@ -56,42 +56,64 @@ class LambdaPodSpecFactoryTest {
List.of(), false, "index.handler", null, 256, Optional.empty());
}
private static JsonNode spec(JsonNode pod) {
return pod.path("spec");
}
private static List<JsonNode> elements(JsonNode array) {
var list = new ArrayList<JsonNode>();
array.forEach(list::add);
return list;
}
private static List<String> texts(JsonNode array) {
return elements(array).stream().map(JsonNode::asText).toList();
}
private static Map<String, String> stringMap(JsonNode object) {
var map = new LinkedHashMap<String, String>();
object.fields().forEachRemaining(entry -> map.put(entry.getKey(), entry.getValue().asText()));
return map;
}
@Test
void zipFunctionPodHasInitContainerTaskVolumeAndEnv() {
var spec = buildZipPod().getSpec();
var spec = spec(buildZipPod());
assertThat(spec.getRestartPolicy()).isEqualTo("Never");
assertThat(spec.getTerminationGracePeriodSeconds()).isEqualTo(5L);
assertThat(spec.getInitContainers()).hasSize(1);
assertThat(spec.path("restartPolicy").asText()).isEqualTo("Never");
assertThat(spec.path("terminationGracePeriodSeconds").asLong()).isEqualTo(5L);
var initContainers = elements(spec.path("initContainers"));
assertThat(initContainers).hasSize(1);
var init = spec.getInitContainers().getFirst();
assertThat(init.getImage()).isEqualTo("busybox:1.36");
assertThat(init.getCommand().get(2))
var init = initContainers.getFirst();
assertThat(init.path("image").asText()).isEqualTo("busybox:1.36");
assertThat(texts(init.path("command")).get(2))
.contains("wget -q -O /tmp/code.zip")
.contains("unzip -oq /tmp/code.zip -d /var/task")
.doesNotContain("--no-check-certificate");
assertThat(init.getVolumeMounts())
.extracting(VolumeMount::getName, VolumeMount::getMountPath)
assertThat(elements(init.path("volumeMounts")))
.extracting(n -> n.path("name").asText(), n -> n.path("mountPath").asText())
.containsExactly(tuple("task", "/var/task"));
var runtime = spec.getContainers().getFirst();
assertThat(runtime.getName()).isEqualTo("runtime");
assertThat(runtime.getArgs()).containsExactly("index.handler");
assertThat(runtime.getResources().getLimits().get("memory")).hasToString("256Mi");
assertThat(runtime.getResources().getRequests().get("memory")).hasToString("256Mi");
assertThat(runtime.getVolumeMounts())
.extracting(VolumeMount::getName, VolumeMount::getMountPath)
var runtime = elements(spec.path("containers")).getFirst();
assertThat(runtime.path("name").asText()).isEqualTo("runtime");
assertThat(texts(runtime.path("args"))).containsExactly("index.handler");
assertThat(runtime.path("resources").path("limits").path("memory").asText()).isEqualTo("256Mi");
assertThat(runtime.path("resources").path("requests").path("memory").asText()).isEqualTo("256Mi");
assertThat(elements(runtime.path("volumeMounts")))
.extracting(n -> n.path("name").asText(), n -> n.path("mountPath").asText())
.contains(tuple("task", "/var/task"));
assertThat(runtime.getEnv())
.extracting(EnvVar::getName, EnvVar::getValue)
assertThat(elements(runtime.path("env")))
.extracting(n -> n.path("name").asText(), n -> n.path("value").asText())
.contains(tuple("AWS_LAMBDA_RUNTIME_API", "10.0.0.5:9200"));
assertThat(spec.getVolumes()).extracting(Volume::getName).containsExactly("task");
assertThat(elements(spec.path("volumes"))).extracting(n -> n.path("name").asText())
.containsExactly("task");
}
@Test
void standardLabelsAreApplied() {
var labels = buildZipPod().getMetadata().getLabels();
var labels = stringMap(buildZipPod().path("metadata").path("labels"));
assertThat(labels)
.containsEntry("app.kubernetes.io/managed-by", "floci")
.containsEntry("floci.io/service", "lambda")
@@ -102,7 +124,7 @@ class LambdaPodSpecFactoryTest {
void userLabelsAreParsedAndApplied() {
when(kubernetes.labels()).thenReturn(Optional.of(
List.of("team=platform", "floci.io/env=ci", "empty-ok=")));
var labels = buildZipPod().getMetadata().getLabels();
var labels = stringMap(buildZipPod().path("metadata").path("labels"));
assertThat(labels)
.containsEntry("team", "platform")
.containsEntry("floci.io/env", "ci")
@@ -115,7 +137,7 @@ class LambdaPodSpecFactoryTest {
// such entries must never reach the pod spec.
when(kubernetes.labels()).thenReturn(Optional.of(
List.of("malformed", "a=b=c", "bad key=x", "team=platform")));
var labels = buildZipPod().getMetadata().getLabels();
var labels = stringMap(buildZipPod().path("metadata").path("labels"));
assertThat(labels)
.containsEntry("team", "platform")
.doesNotContainKeys("malformed", "a", "bad key");
@@ -130,16 +152,17 @@ class LambdaPodSpecFactoryTest {
List.of("http://10.0.0.5:4566/b/layers/1", "http://10.0.0.5:4566/b/layers/2"),
false, "index.handler", null, 128, Optional.empty());
var spec = pod.getSpec();
assertThat(spec.getVolumes()).extracting(Volume::getName).contains("opt");
assertThat(spec.getContainers().getFirst().getVolumeMounts())
.extracting(VolumeMount::getName, VolumeMount::getMountPath)
var spec = spec(pod);
assertThat(elements(spec.path("volumes"))).extracting(n -> n.path("name").asText()).contains("opt");
assertThat(elements(elements(spec.path("containers")).getFirst().path("volumeMounts")))
.extracting(n -> n.path("name").asText(), n -> n.path("mountPath").asText())
.contains(tuple("opt", "/opt"));
assertThat(spec.getInitContainers().getFirst().getVolumeMounts())
.extracting(VolumeMount::getName, VolumeMount::getMountPath)
var init = elements(spec.path("initContainers")).getFirst();
assertThat(elements(init.path("volumeMounts")))
.extracting(n -> n.path("name").asText(), n -> n.path("mountPath").asText())
.contains(tuple("opt", "/opt"));
assertThat(spec.getInitContainers().getFirst().getCommand().get(2))
assertThat(texts(init.path("command")).get(2))
.contains("unzip -oq /tmp/layer0.zip -d /opt")
.containsSubsequence(
"wget -q -O /tmp/layer0.zip 'http://10.0.0.5:4566/b/layers/1'",
@@ -156,15 +179,16 @@ class LambdaPodSpecFactoryTest {
"http://10.0.0.5:4566/awslambda-us-east-1-tasks/snapshots/000000000000/custom",
List.of(), true, "bootstrap", null, 128, Optional.empty());
var spec = pod.getSpec();
assertThat(spec.getVolumes()).extracting(Volume::getName).contains("runtime");
assertThat(spec.getContainers().getFirst().getVolumeMounts())
.extracting(VolumeMount::getName, VolumeMount::getMountPath)
var spec = spec(pod);
assertThat(elements(spec.path("volumes"))).extracting(n -> n.path("name").asText()).contains("runtime");
assertThat(elements(elements(spec.path("containers")).getFirst().path("volumeMounts")))
.extracting(n -> n.path("name").asText(), n -> n.path("mountPath").asText())
.contains(tuple("runtime", "/var/runtime"));
assertThat(spec.getInitContainers().getFirst().getVolumeMounts())
.extracting(VolumeMount::getName)
var init = elements(spec.path("initContainers")).getFirst();
assertThat(elements(init.path("volumeMounts")))
.extracting(n -> n.path("name").asText())
.contains("runtime");
assertThat(spec.getInitContainers().getFirst().getCommand().get(2))
assertThat(texts(init.path("command")).get(2))
.contains("cp /var/task/bootstrap /var/runtime/bootstrap")
.contains("chmod +x /var/runtime/bootstrap");
}
@@ -172,8 +196,8 @@ class LambdaPodSpecFactoryTest {
@Test
void nonProvidedRuntimeDoesNotMaskVarRuntime() {
// Masking /var/runtime on a normal runtime would delete the runtime interface client.
assertThat(buildZipPod().getSpec().getVolumes())
.extracting(Volume::getName)
assertThat(elements(spec(buildZipPod()).path("volumes")))
.extracting(n -> n.path("name").asText())
.doesNotContain("runtime");
}
@@ -181,7 +205,7 @@ class LambdaPodSpecFactoryTest {
void managedLabelsCannotBeOverriddenByUserLabels() {
when(kubernetes.labels()).thenReturn(Optional.of(
List.of("app.kubernetes.io/managed-by=evil", "floci.io/service=other")));
var labels = buildZipPod().getMetadata().getLabels();
var labels = stringMap(buildZipPod().path("metadata").path("labels"));
assertThat(labels)
.containsEntry("app.kubernetes.io/managed-by", "floci")
.containsEntry("floci.io/service", "lambda");
@@ -193,8 +217,8 @@ class LambdaPodSpecFactoryTest {
"public.ecr.aws/lambda/python:3.12",
List.of("SECRET=pa$$word", "TEMPLATE=$(HOME)/x"),
"http://10.0.0.5:4566/b/k", List.of(), false, "h", null, 128, Optional.empty());
assertThat(pod.getSpec().getContainers().getFirst().getEnv())
.extracting(EnvVar::getName, EnvVar::getValue)
assertThat(elements(elements(spec(pod).path("containers")).getFirst().path("env")))
.extracting(n -> n.path("name").asText(), n -> n.path("value").asText())
.contains(
tuple("SECRET", "pa$$$$word"),
tuple("TEMPLATE", "$$(HOME)/x"));
@@ -212,17 +236,20 @@ class LambdaPodSpecFactoryTest {
List.of(), false, "index.handler", null, 128,
Optional.of(KubernetesPodLauncher.CA_CONFIG_MAP_NAME));
var spec = pod.getSpec();
assertThat(spec.getVolumes()).anySatisfy(volume -> {
assertThat(volume.getName()).isEqualTo("floci-ca");
assertThat(volume.getConfigMap().getName()).isEqualTo(KubernetesPodLauncher.CA_CONFIG_MAP_NAME);
var spec = spec(pod);
assertThat(elements(spec.path("volumes"))).anySatisfy(volume -> {
assertThat(volume.path("name").asText()).isEqualTo("floci-ca");
assertThat(volume.path("configMap").path("name").asText())
.isEqualTo(KubernetesPodLauncher.CA_CONFIG_MAP_NAME);
});
assertThat(spec.getContainers().getFirst().getVolumeMounts()).anySatisfy(volumeMount -> {
assertThat(volumeMount.getName()).isEqualTo("floci-ca");
assertThat(volumeMount.getMountPath()).isEqualTo("/etc/floci-ca.crt");
assertThat(volumeMount.getSubPath()).isEqualTo(KubernetesPodLauncher.CA_CONFIG_MAP_KEY);
});
assertThat(spec.getInitContainers().getFirst().getCommand().get(2))
assertThat(elements(elements(spec.path("containers")).getFirst().path("volumeMounts")))
.anySatisfy(volumeMount -> {
assertThat(volumeMount.path("name").asText()).isEqualTo("floci-ca");
assertThat(volumeMount.path("mountPath").asText()).isEqualTo("/etc/floci-ca.crt");
assertThat(volumeMount.path("subPath").asText())
.isEqualTo(KubernetesPodLauncher.CA_CONFIG_MAP_KEY);
});
assertThat(texts(elements(spec.path("initContainers")).getFirst().path("command")).get(2))
.contains("wget -q")
.doesNotContain("--no-check-certificate");
}
@@ -235,7 +262,7 @@ class LambdaPodSpecFactoryTest {
new LambdaPodSpecFactory.ImageConfig(
List.of("/entry.sh"), List.of("run('$(AWS_REGION)')", "pa$$word"), "/work"),
512, Optional.empty());
assertThat(pod.getSpec().getContainers().getFirst().getArgs())
assertThat(texts(elements(spec(pod).path("containers")).getFirst().path("args")))
.containsExactly("run('$$(AWS_REGION)')", "pa$$$$word");
}
@@ -248,14 +275,14 @@ class LambdaPodSpecFactoryTest {
List.of("/entry.sh"), List.of("arg1", "arg2"), "/work"),
512, Optional.empty());
var spec = pod.getSpec();
assertThat(spec.getInitContainers()).isEmpty();
assertThat(spec.getVolumes()).isEmpty();
var spec = spec(pod);
assertThat(elements(spec.path("initContainers"))).isEmpty();
assertThat(elements(spec.path("volumes"))).isEmpty();
var runtime = spec.getContainers().getFirst();
assertThat(runtime.getCommand()).containsExactly("/entry.sh");
assertThat(runtime.getArgs()).containsExactly("arg1", "arg2");
assertThat(runtime.getWorkingDir()).isEqualTo("/work");
var runtime = elements(spec.path("containers")).getFirst();
assertThat(texts(runtime.path("command"))).containsExactly("/entry.sh");
assertThat(texts(runtime.path("args"))).containsExactly("arg1", "arg2");
assertThat(runtime.path("workingDir").asText()).isEqualTo("/work");
}
@Test
@@ -264,8 +291,8 @@ class LambdaPodSpecFactoryTest {
"public.ecr.aws/lambda/python:3.12",
List.of("KEY=a=b", "EMPTY="),
"http://10.0.0.5:4566/b/k", List.of(), false, "h", null, 128, Optional.empty());
assertThat(pod.getSpec().getContainers().getFirst().getEnv())
.extracting(EnvVar::getName, EnvVar::getValue)
assertThat(elements(elements(spec(pod).path("containers")).getFirst().path("env")))
.extracting(n -> n.path("name").asText(), n -> n.path("value").asText())
.contains(
tuple("KEY", "a=b"),
tuple("EMPTY", ""));
@@ -278,8 +305,8 @@ class LambdaPodSpecFactoryTest {
"public.ecr.aws/lambda/python:3.12",
List.of("=oops", "KEY=1"),
"http://10.0.0.5:4566/b/k", List.of(), false, "h", null, 128, Optional.empty());
assertThat(pod.getSpec().getContainers().getFirst().getEnv())
.extracting(EnvVar::getName)
assertThat(elements(elements(spec(pod).path("containers")).getFirst().path("env")))
.extracting(n -> n.path("name").asText())
.containsExactly("KEY");
}