diff --git a/backend/src/main/java/org/cryptomator/hub/config/HubConfig.java b/backend/src/main/java/org/cryptomator/hub/config/HubConfig.java index 971859e3..f3e53899 100644 --- a/backend/src/main/java/org/cryptomator/hub/config/HubConfig.java +++ b/backend/src/main/java/org/cryptomator/hub/config/HubConfig.java @@ -16,15 +16,13 @@ public class HubConfig implements ConfigSource { private static final Logger LOG = Logger.getLogger(HubConfig.class); private static final String HUB_CONFIGSOURCE_NAME = "HubConfig"; - private static final String HUB_CONFIGPATH_PROPERTY_KEY = "hub.config.path"; private final HubConfigPersistence persistence; private final Properties config; - public HubConfig() { - var configPath = System.getProperty(HUB_CONFIGPATH_PROPERTY_KEY); + public HubConfig(String configPath) { if (configPath == null) { - throw new IllegalStateException("Property " + HUB_CONFIGPATH_PROPERTY_KEY + " not set."); + throw new IllegalStateException("Hub config path not set."); } LOG.info("Hub config persists to " + configPath); diff --git a/backend/src/main/java/org/cryptomator/hub/config/HubConfigSourceFactory.java b/backend/src/main/java/org/cryptomator/hub/config/HubConfigSourceFactory.java new file mode 100644 index 00000000..917e1058 --- /dev/null +++ b/backend/src/main/java/org/cryptomator/hub/config/HubConfigSourceFactory.java @@ -0,0 +1,19 @@ +package org.cryptomator.hub.config; + +import io.smallrye.config.ConfigSourceContext; +import io.smallrye.config.ConfigSourceFactory; +import org.eclipse.microprofile.config.spi.ConfigSource; + +import java.util.List; + +public class HubConfigSourceFactory implements ConfigSourceFactory { + + private static final String HUBCONFIG_PROPERTY_KEY = "hub.config.path"; + + @Override + public Iterable getConfigSources(ConfigSourceContext configSourceContext) { + var configPath = configSourceContext.getValue(HUBCONFIG_PROPERTY_KEY); + var hubConfig = new HubConfig(configPath.getValue()); + return List.of(hubConfig); + } +} diff --git a/backend/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceFactory b/backend/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceFactory new file mode 100644 index 00000000..5c77e234 --- /dev/null +++ b/backend/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceFactory @@ -0,0 +1 @@ +org.cryptomator.hub.config.HubConfigSourceFactory \ No newline at end of file diff --git a/backend/src/main/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSource b/backend/src/main/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSource deleted file mode 100644 index fd571d73..00000000 --- a/backend/src/main/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSource +++ /dev/null @@ -1 +0,0 @@ -org.cryptomator.hub.config.HubConfig \ No newline at end of file diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index 41d24ac7..7b8e56cf 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -8,6 +8,9 @@ quarkus.http.port=9090 quarkus.oidc.application-type=service quarkus.oidc.client-id=cryptomator-hub +hub.config.path=hub.properties +%test.hub.config.path=target/hub-test.properties + # Keycloak dev service %dev.quarkus.keycloak.devservices.enabled=true %dev.quarkus.keycloak.devservices.create-realm=false