mirror of
https://github.com/floci-io/floci-cli.git
synced 2026-11-25 06:47:41 -05:00
fix(start): mount a relative --persist path as a directory and validate --port and --pull
--persist ./data is resolved to an absolute path and created before docker run, so state lands in that directory instead of a Docker named volume; --port outside 1-65535 and an unknown --pull policy are rejected with exit 2 (restart checks them before stopping anything). start creates the persist directory itself (preparePersistDir). restart now does that before it stops anything, so an unwritable directory fails the restart with the instance still running, instead of after the container was already removed.
This commit is contained in:
4 files changed
+102
-1
No files matched your search
@@ -191,6 +191,27 @@ class StartCommandArgsTest {
|
||||
.dockerRunArgs(SOCKET).contains("FLOCI_BASE_URL=http://floci.internal:14566"));
|
||||
}
|
||||
|
||||
/** BL-034: Docker reads "./data:/app/data" as a named volume, so the path goes in absolute. */
|
||||
@Test
|
||||
void aRelativePersistDirIsMountedAsAnAbsoluteBindPath() {
|
||||
String expected = Path.of("data").toAbsolutePath().normalize() + ":/app/data";
|
||||
|
||||
List<String> args = parse("start", "--persist", "./data").dockerRunArgs(SOCKET);
|
||||
|
||||
assertTrue(args.contains(expected), args.toString());
|
||||
assertFalse(args.contains("./data:/app/data"), args.toString());
|
||||
}
|
||||
|
||||
/** BL-035: an out-of-range port or an unknown pull policy is refused before docker runs. */
|
||||
@Test
|
||||
void portAndPullPolicyAreValidated() {
|
||||
assertNull(parse("start").validationError());
|
||||
assertNull(parse("start", "--pull", "ALWAYS").validationError());
|
||||
assertTrue(parse("start", "--port", "0").validationError().contains("--port must be between 1 and 65535"));
|
||||
assertTrue(parse("start", "--port", "70000").validationError().contains("--port must be between 1 and 65535"));
|
||||
assertTrue(parse("start", "--pull", "alwayz").validationError().contains("Invalid --pull 'alwayz'"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void readinessPollKeepsTheHostFromTheEndpointWhenSwappingThePort() {
|
||||
assertEquals("http://floci.internal:4599", StartCommand.withPort("http://floci.internal:4566", 4599));
|
||||
|
||||
Reference in new issue
Block a user