Light, fluffy, and always free - The AWS Local Emulator alternative
fix(cloudformation): key the Lambda hot-reload identity on the Docker host path (#4275)
Hector Ventura69217dff2a57
diff --git a/src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners/LambdaCfnProvisioner.java b/src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners/LambdaCfnProvisioner.javaindex 859d498afa..d57995f41d 100644--- a/src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners/LambdaCfnProvisioner.java+++ b/src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners/LambdaCfnProvisioner.java@@ -407,14 +407,16 @@ public class LambdaCfnProvisioner implements CfnResourceProvisioner {/*** The form LambdaService stores a hot-reload host path in: normalized, so {@code /a/../b/}- * and {@code /b} are the same mount. Identities and change detection use it so a redeploy- * that only rewrites the path spelling, or a function adopted from a direct CreateFunction,- * is not mistaken for a code change. The raw key still goes to Lambda, which validates it and- * reports its own error for a path it cannot use.+ * and {@code /b} are the same mount, and rendered as the POSIX path Docker receives+ * ({@link LambdaService#toDockerHostPath}), so the identity agrees with+ * {@code getHotReloadHostPath()} on every host separator. Identities and change detection use+ * it so a redeploy that only rewrites the path spelling, or a function adopted from a direct+ * CreateFunction, is not mistaken for a code change. The raw key still goes to Lambda, which+ * validates it and reports its own error for a path it cannot use.*/private static String canonicalHotReloadPath(String s3Key) {try {- return Path.of(s3Key).normalize().toString();+ return LambdaService.toDockerHostPath(Path.of(s3Key).normalize());} catch (InvalidPathException e) {return s3Key;}diff --git a/src/main/java/io/github/hectorvent/floci/services/lambda/LambdaService.java b/src/main/java/io/github/hectorvent/floci/services/lambda/LambdaService.javaindex 5b8e490231..bc73712385 100644--- a/src/main/java/io/github/hectorvent/floci/services/lambda/LambdaService.java+++ b/src/main/java/io/github/hectorvent/floci/services/lambda/LambdaService.java@@ -3011,8 +3011,12 @@ public class LambdaService implements ResourceProvider {LOG.infov("Hot-reload configured for function {0}: bind-mounting {1}", fn.getFunctionName(), resolvedHostPath);}- /** Docker on the host expects a POSIX path, whatever separator the JVM running Floci uses. */- static String toDockerHostPath(Path normalized) {+ /**+ * Docker on the host expects a POSIX path, whatever separator the JVM running Floci uses.+ * Public because the CloudFormation provisioner keys its hot-reload identity on the same form,+ * so change detection agrees with what {@link #applyHotReload} stored.+ */+ public static String toDockerHostPath(Path normalized) {StringBuilder path = new StringBuilder();for (Path name : normalized) {path.append('/').append(name);