Skip to content

Commit b9da190

Browse files
committed
Allow Application Client Specific Customizations
Only installation clients may be configured with a rate limit checker. This change allows for application vs installation client customizations, so that the rate limit checker may be configured for the installation client but not the application client.
1 parent a5ff77a commit b9da190

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

runtime/src/main/java/io/quarkiverse/githubapp/GitHubCustomizer.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ public interface GitHubCustomizer {
1010

1111
/**
1212
* Customize the {@link GitHubBuilder} with various options.
13+
*
14+
* <p>
15+
* These customizations are applied to both application and installation clients. Known cases of customizations that
16+
* may be used with installation clients but not with application clients include configuring a rate limit checker. To use a
17+
* different set of customizations for the application client, implement {@link #customizeApplicationClient(GitHubBuilder)}.
1318
* <p>
1419
* Note that customizations that use {@link GitHubBuilder#withAppInstallationToken(String)} and
1520
* {@link GitHubBuilder#withEndpoint(String)} are eventually overridden by the
@@ -21,4 +26,22 @@ public interface GitHubCustomizer {
2126
* @param builder to customize
2227
*/
2328
void customize(GitHubBuilder builder);
29+
30+
/**
31+
* Customize the {@link GitHubBuilder} with various options specifically for the application client. Default implementation
32+
* delegates to {@link #customize(GitHubBuilder)} for backwards compatibility.
33+
* <p>
34+
* Note that customizations should never use {@link GitHubBuilder#withAppInstallationToken(String)}, because this is the
35+
* application client. Customizations that use {@link GitHubBuilder#withJwtToken(String)} and
36+
* {@link GitHubBuilder#withEndpoint(String)} are eventually overridden by the service.
37+
*
38+
* <p>
39+
* To specify a custom endpoint, use configuration properties {@code quarkus.github-app.instance-endpoint} or
40+
* {@code quarkus.github-app.rest-api-endpoint}.
41+
*
42+
* @param builder to customize
43+
*/
44+
default void customizeApplicationClient(GitHubBuilder builder) {
45+
customize(builder);
46+
}
2447
}

runtime/src/main/java/io/quarkiverse/githubapp/runtime/github/GitHubService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ private GitHub createApplicationGitHub() {
292292
final GitHubBuilder gitHubBuilder = new GitHubBuilder()
293293
.withConnector(gitHubConnector);
294294
// apply customizations
295-
githubCustomizer.customize(gitHubBuilder);
295+
githubCustomizer.customizeApplicationClient(gitHubBuilder);
296296
// configure mandatory defaults
297297
gitHubBuilder
298298
.withJwtToken(jwtToken)

0 commit comments

Comments
 (0)