Skip to content

Commit f9a2bb8

Browse files
coopernetesclaude
andcommitted
refactor: replace hand-rolled SnakeYAML loader with Gestalt config
Replaces JettyConfigurationLoader (raw Map drilling, @SuppressWarnings) with a typed Gestalt-based config pipeline: - GitProxyConfig and nested POJOs (ServerConfig, DatabaseConfig, ProviderConfig, CommitSettings, FiltersConfig, WhitelistConfig) bind directly from YAML with no manual key lookups - GitProxyConfigLoader merges: classpath base → optional local override → GITPROXY_* env var overrides (highest priority) - JettyConfigurationBuilder now takes GitProxyConfig directly; all unchecked casts and helper getters removed - Flat YAML structure: git-proxy: nesting removed so env var paths are clean (GITPROXY_SERVER_PORT, GITPROXY_DATABASE_TYPE, etc.) - JettyConfigurationLoader and JettyConfigurationLoaderTest deleted - src/test/resources/git-proxy-local.yml shadows the dev local config so unit tests see only base defaults - CONFIGURATION.md rewritten to reflect new structure and env var table Closes #8 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7cd3e08 commit f9a2bb8

25 files changed

Lines changed: 864 additions & 916 deletions

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ ext {
3838
// YAML
3939
snakeyamlVersion = '2.2'
4040

41+
// Gestalt config
42+
gestaltVersion = '0.37.2'
43+
4144
// BouncyCastle
4245
bouncyCastleVersion = '1.83'
4346

docker/git-proxy-local.yml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22
# This file is mounted into the container at /app/conf/git-proxy-local.yml
33
# and overrides the defaults in git-proxy.yml.
44

5-
git-proxy:
6-
providers:
7-
# Disable the default cloud providers; we only need the local Gitea instance.
8-
github:
9-
enabled: false
10-
gitlab:
11-
enabled: false
12-
bitbucket:
13-
enabled: false
5+
providers:
6+
# Disable the default cloud providers; we only need the local Gitea instance.
7+
github:
8+
enabled: false
9+
gitlab:
10+
enabled: false
11+
bitbucket:
12+
enabled: false
1413

15-
# Local Gitea instance.
16-
# Push (store-and-forward): http://localhost:8080/push/gitea/<owner>/<repo>.git
17-
# Proxy (transparent): http://localhost:8080/proxy/gitea/<owner>/<repo>.git
18-
gitea:
19-
enabled: true
20-
uri: http://gitea:3000
21-
servlet-path: /gitea
14+
# Local Gitea instance.
15+
# Push (store-and-forward): http://localhost:8080/push/gitea/<owner>/<repo>.git
16+
# Proxy (transparent): http://localhost:8080/proxy/gitea/<owner>/<repo>.git
17+
gitea:
18+
enabled: true
19+
uri: http://gitea:3000
20+
servlet-path: /gitea

docker/git-proxy-mongo.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ database:
66
url: mongodb://gitproxy:gitproxy@mongo:27017
77
name: gitproxy
88

9-
git-proxy:
10-
providers:
11-
github:
12-
enabled: false
13-
gitlab:
14-
enabled: false
15-
bitbucket:
16-
enabled: false
17-
gitea:
18-
enabled: true
19-
uri: http://gitea:3000
20-
servlet-path: /gitea
9+
providers:
10+
github:
11+
enabled: false
12+
gitlab:
13+
enabled: false
14+
bitbucket:
15+
enabled: false
16+
gitea:
17+
enabled: true
18+
uri: http://gitea:3000
19+
servlet-path: /gitea

docker/git-proxy-postgres.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ database:
1616
username: gitproxy
1717
password: gitproxy
1818

19-
git-proxy:
20-
providers:
21-
github:
22-
enabled: false
23-
gitlab:
24-
enabled: false
25-
bitbucket:
26-
enabled: false
27-
gitea:
28-
enabled: true
29-
uri: http://gitea:3000
30-
servlet-path: /gitea
19+
providers:
20+
github:
21+
enabled: false
22+
gitlab:
23+
enabled: false
24+
bitbucket:
25+
enabled: false
26+
gitea:
27+
enabled: true
28+
uri: http://gitea:3000
29+
servlet-path: /gitea

jgit-proxy-dashboard/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ dependencies {
6060
runtimeOnly "org.postgresql:postgresql:${postgresVersion}"
6161
runtimeOnly "org.mongodb:mongodb-driver-sync:${mongoVersion}"
6262

63-
// YAML config
64-
implementation "org.yaml:snakeyaml:${snakeyamlVersion}"
63+
// Gestalt config (needed to catch GestaltException from GitProxyConfigLoader)
64+
implementation "com.github.gestalt-config:gestalt-core:${gestaltVersion}"
6565

6666
// Lombok
6767
compileOnly "org.projectlombok:lombok:${lombokVersion}"

jgit-proxy-dashboard/src/main/java/org/finos/gitproxy/dashboard/GitProxyWithDashboardApplication.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
import org.finos.gitproxy.db.PushStore;
1515
import org.finos.gitproxy.git.LocalRepositoryCache;
1616
import org.finos.gitproxy.jetty.GitProxyServletRegistrar;
17+
import org.finos.gitproxy.jetty.config.GitProxyConfigLoader;
1718
import org.finos.gitproxy.jetty.config.JettyConfigurationBuilder;
18-
import org.finos.gitproxy.jetty.config.JettyConfigurationLoader;
1919
import org.finos.gitproxy.provider.GitProxyProvider;
2020
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
2121
import org.springframework.web.servlet.DispatcherServlet;
@@ -38,8 +38,7 @@ public static void main(String[] args) throws Exception {
3838
log.info("Starting JGit Proxy with Dashboard...");
3939
writePidFile();
4040

41-
var configLoader = new JettyConfigurationLoader();
42-
var configBuilder = new JettyConfigurationBuilder(configLoader);
41+
var configBuilder = new JettyConfigurationBuilder(GitProxyConfigLoader.load());
4342

4443
var threadPool = new QueuedThreadPool();
4544
threadPool.setName("jgit-proxy-dashboard");

0 commit comments

Comments
 (0)