Skip to content

Commit 97244d2

Browse files
committed
Some very minor refinements + doc
We usually try to avoid lambdas in runtime code as there is a small price to pay. In this case, they are easily avoidable.
1 parent e555167 commit 97244d2

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

docs/modules/ROOT/pages/developer-reference.adoc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,25 @@ You can use the constants present in `io.quarkiverse.githubapp.Credentials` for
370370
That is all you need to do:
371371
Quarkus GitHub App will then automatically use the values provided by the `CredentialsProvider` for the private key and the webhook secret.
372372

373+
== Customizing the GitHub clients
374+
375+
You can customize the GitHub clients initialized by Quarkus GitHub App
376+
by creating a CDI bean implementing `io.quarkiverse.githubapp.GitHubCustomizer`.
377+
378+
For instance:
379+
380+
[source,java]
381+
----
382+
@Singleton
383+
public class MyGitHubCustomizer implements GitHubCustomizer {
384+
385+
@Override
386+
public void customize(GitHubBuilder builder) {
387+
// call methods of the builder
388+
}
389+
}
390+
----
391+
373392
== Architecture Overview
374393

375394
image::architecture.png[Architecture]

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22

33
import org.kohsuke.github.GitHubBuilder;
44

5-
import io.quarkiverse.githubapp.runtime.config.CheckedConfigProvider;
6-
75
/**
8-
* Seam for customizing the {@link GitHubBuilder} used to create the {@link org.kohsuke.github.GitHub} instance.
6+
* Provide a CDI bean implementing this interface to customize {@link GitHubBuilder} used to create the
7+
* {@link org.kohsuke.github.GitHub} instances.
98
*/
109
public interface GitHubCustomizer {
1110

1211
/**
13-
* Customize the {@link GitHubBuilder} with various options for runtime.
12+
* Customize the {@link GitHubBuilder} with various options.
1413
* <p>
1514
* Note that customizations that use {@link GitHubBuilder#withAppInstallationToken(String)} and
1615
* {@link GitHubBuilder#withEndpoint(String)} are eventually overridden by the
1716
* {@link io.quarkiverse.githubapp.runtime.github.GitHubService}. Installation tokens are created and cached by the service.
18-
* To specify a custom endpoint, prefer the {@link CheckedConfigProvider#restApiEndpoint()}
17+
* <p>
18+
* To specify a custom endpoint, use configuration properties {@code quarkus.github-app.instance-endpoint} or
19+
* {@code quarkus.github-app.rest-api-endpoint}.
1920
*
2021
* @param builder to customize
2122
*/

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ public class GitHubService implements GitHubClientProvider {
3535

3636
private static final String AUTHORIZATION_HEADER = "Authorization";
3737
private static final String AUTHORIZATION_HEADER_BEARER = "Bearer %s";
38+
private static final GitHubCustomizer NOOP_GITHUB_CUSTOMIZER = new GitHubCustomizer() {
39+
40+
@Override
41+
public void customize(GitHubBuilder builder) {
42+
}
43+
};
3844

3945
private final CheckedConfigProvider checkedConfigProvider;
4046

@@ -81,8 +87,7 @@ public long expireAfterRead(Long installationId, CachedInstallationToken cachedI
8187
this.gitHubConnector = new HttpClientGitHubConnector(
8288
HttpClient.newBuilder().version(Version.HTTP_1_1).followRedirects(HttpClient.Redirect.NEVER).build());
8389
// if the customizer is not resolvable, we use a no-op customizer
84-
githubCustomizer = gitHubCustomizer.isResolvable() ? gitHubCustomizer.get() : builder -> {
85-
};
90+
githubCustomizer = gitHubCustomizer.isResolvable() ? gitHubCustomizer.get() : NOOP_GITHUB_CUSTOMIZER;
8691
}
8792

8893
@Override

0 commit comments

Comments
 (0)