Skip to content

Commit

Permalink
re-add ConfigSourceFactory from 64d0d5f
Browse files Browse the repository at this point in the history
to be replaced, once there is an official way to access higher-order config (see eclipse/microprofile-config#470)
  • Loading branch information
overheadhunter committed Nov 26, 2021
1 parent 2108874 commit 091b93e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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<ConfigSource> getConfigSources(ConfigSourceContext configSourceContext) {
var configPath = configSourceContext.getValue(HUBCONFIG_PROPERTY_KEY);
var hubConfig = new HubConfig(configPath.getValue());
return List.of(hubConfig);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.cryptomator.hub.config.HubConfigSourceFactory

This file was deleted.

3 changes: 3 additions & 0 deletions backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 091b93e

Please sign in to comment.