Skip to content

Commit 5ed6be5

Browse files
authored
Merge pull request #696 from gsmet/minor-adjustments
Minor adjustments
2 parents 60e4ce2 + 064c80c commit 5ed6be5

File tree

6 files changed

+58
-13
lines changed

6 files changed

+58
-13
lines changed

command-airline/runtime/src/main/codestarts/quarkus/quarkiverse-github-app-command-airline-codestart/java/src/main/java/org/acme/MyGitHubBot.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.acme;
22

33
import java.io.IOException;
4+
import java.util.ArrayList;
45
import java.util.List;
56

67
import org.kohsuke.github.GHEventPayload;
@@ -24,12 +25,12 @@ interface Commands {
2425
static class SayHello implements Commands {
2526

2627
@Arguments
27-
List<String> arguments;
28+
List<String> arguments = new ArrayList<>();
2829

2930
@Override
3031
public void run(GHEventPayload.IssueComment issueCommentPayload) throws IOException {
3132
issueCommentPayload.getIssue()
32-
.comment(":wave: Hello " + (arguments != null ? String.join(" ", arguments) : "from Bot"));
33+
.comment(":wave: Hello " + String.join(" ", arguments));
3334
}
3435
}
3536

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,39 @@ public class MyGitHubCustomizer implements GitHubCustomizer {
419419
}
420420
----
421421

422+
This will apply the customizations to both the application clients and the installation clients.
423+
424+
However, some customizations can't be applied to the application clients such as configuring a rate limit checker.
425+
You may customize the application clients differently by implementing `customizeApplicationClient(GitHubBuilder)`:
426+
427+
[source,java]
428+
----
429+
@Singleton
430+
public class MyGitHubCustomizer implements GitHubCustomizer {
431+
432+
@Override
433+
public void customize(GitHubBuilder builder) { <1>
434+
// call methods of the builder
435+
}
436+
437+
@Override
438+
public void customizeApplicationClient(GitHubBuilder builder) { <2>
439+
// call methods of the builder
440+
}
441+
}
442+
----
443+
<1> Customize the installation clients.
444+
<2> Customize the application clients.
445+
446+
[NOTE]
447+
.About application and installation clients
448+
====
449+
A GitHub App relies on two types of GitHub clients:
450+
451+
- The application client: it is authenticated as the application, it has very few permissions and is mostly used to create installation-specific tokens.
452+
- The installation client: it is created specifically for an installation of the application (i.e. it is tied where the application is installed) and it is the client you consume in your GitHub App code. It has the permissions you defined for your GitHub App.
453+
====
454+
422455
== Configuration Reference
423456

424457
The Quarkus GitHub App extension exposes the following configuration properties:

docs/modules/ROOT/pages/includes/attributes.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
:quarkus-version: 3.17.0
1+
:quarkus-version: 3.15.2
22
:quarkus-github-app-version: 2.8.0
33

44
:github-api-javadoc-root-url: https://github-api.kohsuke.org/apidocs/org/kohsuke/github

integration-tests/command-airline/src/test/resources/__snapshots__/CodestartTest/testContent/src_main_java_ilove_quark_us_MyGitHubBot.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package ilove.quark.us;
22

33
import java.io.IOException;
4+
import java.util.ArrayList;
45
import java.util.List;
56

67
import org.kohsuke.github.GHEventPayload;
@@ -24,12 +25,12 @@ interface Commands {
2425
static class SayHello implements Commands {
2526

2627
@Arguments
27-
List<String> arguments;
28+
List<String> arguments = new ArrayList<>();
2829

2930
@Override
3031
public void run(GHEventPayload.IssueComment issueCommentPayload) throws IOException {
3132
issueCommentPayload.getIssue()
32-
.comment(":wave: Hello " + (arguments != null ? String.join(" ", arguments) : "from Bot"));
33+
.comment(":wave: Hello " + String.join(" ", arguments));
3334
}
3435
}
3536

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<maven.compiler.target>17</maven.compiler.target>
2222
<maven.compiler.release>17</maven.compiler.release>
2323
<maven.compiler.parameters>true</maven.compiler.parameters>
24-
<quarkus.version>3.17.2</quarkus.version>
24+
<quarkus.version>3.15.2</quarkus.version>
2525
<compiler-plugin.version>3.13.0</compiler-plugin.version>
2626
<resource-plugin.version>3.3.1</resource-plugin.version>
2727
<dependency-plugin.version>3.8.1</dependency-plugin.version>

runtime/src/main/java/io/quarkiverse/githubapp/runtime/error/DefaultErrorHandler.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.quarkiverse.githubapp.runtime.error;
22

3+
import java.util.ArrayList;
4+
import java.util.List;
35
import java.util.Optional;
46

57
import jakarta.enterprise.context.ApplicationScoped;
@@ -30,37 +32,45 @@ public class DefaultErrorHandler implements ErrorHandler {
3032
@Override
3133
public void handleError(GitHubEvent gitHubEvent, GHEventPayload payload, Throwable t) {
3234
StringBuilder errorMessage = new StringBuilder();
33-
errorMessage.append("Error handling delivery " + gitHubEvent.getDeliveryId() + "\n");
35+
List<String> errorMessageParameters = new ArrayList<>();
36+
37+
errorMessage.append("Error handling delivery {").append(errorMessageParameters.size()).append("}\n");
38+
errorMessageParameters.add(gitHubEvent.getDeliveryId());
3439
if (t instanceof ServiceDownException || t instanceof GitHubServiceDownException) {
3540
errorMessage
3641
.append("››› GitHub APIs are not available at the moment. Have a look at https://www.githubstatus.com.\n");
3742
}
3843
if (gitHubEvent.getRepository().isPresent()) {
39-
errorMessage.append("› Repository: " + gitHubEvent.getRepository().get() + "\n");
44+
errorMessage.append("› Repository: {").append(errorMessageParameters.size()).append("}\n");
45+
errorMessageParameters.add(gitHubEvent.getRepository().get());
4046
}
41-
errorMessage.append("› Event: " + gitHubEvent.getEventAction() + "\n");
47+
errorMessage.append("› Event: {").append(errorMessageParameters.size()).append("}\n");
48+
errorMessageParameters.add(gitHubEvent.getEventAction());
4249

4350
if (payload != null) {
4451
Optional<String> context = PayloadHelper.getContext(payload);
4552
if (context.isPresent()) {
46-
errorMessage.append("› Context: " + PayloadHelper.getContext(payload).get() + "\n");
53+
errorMessage.append("› Context: {").append(errorMessageParameters.size()).append("}\n");
54+
errorMessageParameters.add(context.get());
4755
}
4856
}
4957

5058
if (gitHubEvent.getAppName().isPresent()) {
51-
errorMessage.append("› Redeliver: " + String.format(REDELIVERY_URL, gitHubEvent.getAppName().get()) + "\n");
59+
errorMessage.append("› Redeliver: {").append(errorMessageParameters.size()).append("}\n");
60+
errorMessageParameters.add(String.format(REDELIVERY_URL, gitHubEvent.getAppName().get()));
5261
}
5362

5463
if (launchMode.isDevOrTest()) {
5564
errorMessage.append("› Payload:\n")
5665
.append("----\n")
57-
.append(gitHubEvent.getParsedPayload().encodePrettily()).append("\n")
66+
.append("{").append(errorMessageParameters.size()).append("}\n")
5867
.append("----\n");
68+
errorMessageParameters.add(gitHubEvent.getParsedPayload().encodePrettily());
5969
}
6070

6171
errorMessage.append("Exception");
6272

63-
LOG.error(errorMessage.toString(), t);
73+
LOG.errorv(t, errorMessage.toString(), errorMessageParameters.toArray());
6474
}
6575

6676
}

0 commit comments

Comments
 (0)