Skip to content
Snippets Groups Projects
Commit f47c821a authored by Zachary Sabourin's avatar Zachary Sabourin
Browse files

feat: Standardize configurations

Relates to eclipsefdn/it/api/eclipsefdn-project-adopters#200
parent adcca489
No related branches found
No related tags found
No related merge requests found
......@@ -61,12 +61,8 @@ import io.quarkus.runtime.Startup;
public class DefaultAdopterService implements AdopterService {
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultAdopterService.class);
@ConfigProperty(name = "eclipse.adopters.path.json", defaultValue = "/tmp/quarkus/adopters.json")
Path adoptersLocation;
@ConfigProperty(name = "eclipse.adopters.retry.count", defaultValue = "3")
int retryCount;
@ConfigProperty(name = "eclipse.adopters.retry.timeoutInMS", defaultValue = "1000")
long retryTimeout;
@ConfigProperty(name = "eclipse.project-adopters.adopters.filepath", defaultValue = "/tmp/quarkus/adopters.json")
Path adoptersFilepath;
@Inject
ObjectMapper objectMapper;
......@@ -83,14 +79,14 @@ public class DefaultAdopterService implements AdopterService {
public void init() throws IOException {
setAdopters(Collections.emptyList());
// attempt to ensure that the base directory exists for watching
Path parentDir = adoptersLocation.getParent();
Path parentDir = adoptersFilepath.getParent();
if (!Files.exists(parentDir)) {
Files.createDirectory(parentDir);
}
// read in the initial file if it exists
if (Files.exists(adoptersLocation)) {
LOGGER.debug("Found an adopters file at path {}, reading in", adoptersLocation);
List<Adopter> initialAdopters = readInAdopters(adoptersLocation, objectMapper);
if (Files.exists(adoptersFilepath)) {
LOGGER.debug("Found an adopters file at path {}, reading in", adoptersFilepath);
List<Adopter> initialAdopters = readInAdopters(adoptersFilepath, objectMapper);
if (initialAdopters != null) {
setAdopters(initialAdopters);
......@@ -133,7 +129,7 @@ public class DefaultAdopterService implements AdopterService {
// pass a filtered list of events to be processed
key.pollEvents().stream().filter(e -> e.kind() != OVERFLOW && e.kind().type() == Path.class)
.map(e -> (WatchEvent<Path>) e)
.filter(e -> ((Path) e.context()).getFileName().equals(adoptersLocation.getFileName()))
.filter(e -> ((Path) e.context()).getFileName().equals(adoptersFilepath.getFileName()))
.forEach(this::processEvent);
} catch (@SuppressWarnings("java:S2142") InterruptedException e) {
LOGGER.debug("Ending watch services, as thread was interrupted and closing");
......@@ -161,7 +157,7 @@ public class DefaultAdopterService implements AdopterService {
} else {
// indicates an update or created file on the given
// retrieve the new adopters and set them if the read operation was successful
List<Adopter> newAdopters = readInAdopters(adoptersLocation, objectMapper);
List<Adopter> newAdopters = readInAdopters(adoptersFilepath, objectMapper);
if (newAdopters != null) {
setAdopters(newAdopters);
}
......
org.eclipsefoundation.adopters.api.ProjectsAPI/mp-rest/url=https://projects.eclipse.org
## OAUTH CONFIG
quarkus.http.root-path=/adopters
quarkus.log.level=INFO
## CORS settings
quarkus.http.cors=false
quarkus.log.level=INFO
## OIDC settings
quarkus.oidc.enabled=false
## Adopters raw location
eclipse.adopters.path.json=/config/adopters.json
%dev.eclipse.adopters.path.json=/tmp/config/adopters.json
# Projects-API
org.eclipsefoundation.adopters.api.ProjectsAPI/mp-rest/url=https://projects.eclipse.org
## Adopters settings
eclipse.project-adopters.adopters.filepath=/config/adopters.json
%dev.eclipse.project-adopters.adopters.filepath=/tmp/config/adopters.json
%dev.eclipse.pagination.scheme.enforce=false
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment