mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(core): let a native host path follow a configured persistent path (#5777)
HostDefaultsConfigSource set floci.storage.host-persistent-path to the user
data directory as a fixed value. A persistent path set only in
config/application.yml then moved the state but not the directory child
containers bind. The host path now defaults to ${floci.storage.persistent-path},
so it follows whichever persistent path wins, and an explicit host path still
takes precedence.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
1 parent
e24a2882bc
commit
f897dfc3b6
2 files changed
+36
-3
No files matched your search
@@ -1,7 +1,13 @@
|
||||
package io.github.hectorvent.floci.config;
|
||||
|
||||
import io.smallrye.config.PropertiesConfigSource;
|
||||
import io.smallrye.config.SmallRyeConfig;
|
||||
import io.smallrye.config.SmallRyeConfigBuilder;
|
||||
import org.eclipse.microprofile.config.spi.ConfigSource;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.aMapWithSize;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
@@ -27,8 +33,28 @@ class HostDefaultsConfigSourceTest {
|
||||
@Test
|
||||
void nativeHostRunSetsBothPathsToTheSameDirectory() {
|
||||
HostDefaultsConfigSource source = new HostDefaultsConfigSource(true);
|
||||
SmallRyeConfig config = configWith(source);
|
||||
String dir = source.getValue(HostDefaultsConfigSource.PERSISTENT_PATH);
|
||||
assertThat(source.getValue(HostDefaultsConfigSource.HOST_PERSISTENT_PATH), equalTo(dir));
|
||||
assertThat(config.getValue(HostDefaultsConfigSource.PERSISTENT_PATH, String.class), equalTo(dir));
|
||||
assertThat(config.getValue(HostDefaultsConfigSource.HOST_PERSISTENT_PATH, String.class), equalTo(dir));
|
||||
}
|
||||
|
||||
@Test
|
||||
void hostPathFollowsAPersistentPathTheUserConfigures() {
|
||||
SmallRyeConfig config = configWith(new HostDefaultsConfigSource(true),
|
||||
new PropertiesConfigSource(Map.of(HostDefaultsConfigSource.PERSISTENT_PATH, "/srv/floci"),
|
||||
"config/application.yml", 265));
|
||||
assertThat(config.getValue(HostDefaultsConfigSource.HOST_PERSISTENT_PATH, String.class),
|
||||
equalTo("/srv/floci"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anExplicitHostPathStillWins() {
|
||||
SmallRyeConfig config = configWith(new HostDefaultsConfigSource(true),
|
||||
new PropertiesConfigSource(Map.of(HostDefaultsConfigSource.PERSISTENT_PATH, "/srv/floci",
|
||||
HostDefaultsConfigSource.HOST_PERSISTENT_PATH, "/mnt/floci"), "env", 300));
|
||||
assertThat(config.getValue(HostDefaultsConfigSource.HOST_PERSISTENT_PATH, String.class),
|
||||
equalTo("/mnt/floci"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -36,4 +62,9 @@ class HostDefaultsConfigSourceTest {
|
||||
// classpath application.yml is 255, config/application.yml in the working directory 265.
|
||||
assertThat(new HostDefaultsConfigSource(false).getOrdinal(), allOf(greaterThan(255), lessThan(265)));
|
||||
}
|
||||
|
||||
private static SmallRyeConfig configWith(ConfigSource... sources) {
|
||||
// The default interceptors expand ${...} expressions, as the runtime config does.
|
||||
return new SmallRyeConfigBuilder().addDefaultInterceptors().withSources(sources).build();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user