Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor adjustments #696

Merged
merged 5 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.acme;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

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

@Arguments
List<String> arguments;
List<String> arguments = new ArrayList<>();

@Override
public void run(GHEventPayload.IssueComment issueCommentPayload) throws IOException {
issueCommentPayload.getIssue()
.comment(":wave: Hello " + (arguments != null ? String.join(" ", arguments) : "from Bot"));
.comment(":wave: Hello " + String.join(" ", arguments));
}
}

Expand Down
33 changes: 33 additions & 0 deletions docs/modules/ROOT/pages/developer-reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,39 @@ public class MyGitHubCustomizer implements GitHubCustomizer {
}
----

This will apply the customizations to both the application clients and the installation clients.

However, some customizations can't be applied to the application clients such as configuring a rate limit checker.
You may customize the application clients differently by implementing `customizeApplicationClient(GitHubBuilder)`:

[source,java]
----
@Singleton
public class MyGitHubCustomizer implements GitHubCustomizer {

@Override
public void customize(GitHubBuilder builder) { <1>
// call methods of the builder
}

@Override
public void customizeApplicationClient(GitHubBuilder builder) { <2>
// call methods of the builder
}
}
----
<1> Customize the installation clients.
<2> Customize the application clients.

[NOTE]
.About application and installation clients
====
A GitHub App relies on two types of GitHub clients:

- The application client: it is authenticated as the application, it has very few permissions and is mostly used to create installation-specific tokens.
- 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.
====

== Configuration Reference

The Quarkus GitHub App extension exposes the following configuration properties:
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/includes/attributes.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:quarkus-version: 3.17.0
:quarkus-version: 3.15.2
:quarkus-github-app-version: 2.8.0

:github-api-javadoc-root-url: https://github-api.kohsuke.org/apidocs/org/kohsuke/github
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ilove.quark.us;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

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

@Arguments
List<String> arguments;
List<String> arguments = new ArrayList<>();

@Override
public void run(GHEventPayload.IssueComment issueCommentPayload) throws IOException {
issueCommentPayload.getIssue()
.comment(":wave: Hello " + (arguments != null ? String.join(" ", arguments) : "from Bot"));
.comment(":wave: Hello " + String.join(" ", arguments));
}
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.release>17</maven.compiler.release>
<maven.compiler.parameters>true</maven.compiler.parameters>
<quarkus.version>3.17.2</quarkus.version>
<quarkus.version>3.15.2</quarkus.version>
<compiler-plugin.version>3.13.0</compiler-plugin.version>
<resource-plugin.version>3.3.1</resource-plugin.version>
<dependency-plugin.version>3.8.1</dependency-plugin.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.quarkiverse.githubapp.runtime.error;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import jakarta.enterprise.context.ApplicationScoped;
Expand Down Expand Up @@ -30,37 +32,45 @@ public class DefaultErrorHandler implements ErrorHandler {
@Override
public void handleError(GitHubEvent gitHubEvent, GHEventPayload payload, Throwable t) {
StringBuilder errorMessage = new StringBuilder();
errorMessage.append("Error handling delivery " + gitHubEvent.getDeliveryId() + "\n");
List<String> errorMessageParameters = new ArrayList<>();

errorMessage.append("Error handling delivery {").append(errorMessageParameters.size()).append("}\n");
errorMessageParameters.add(gitHubEvent.getDeliveryId());
if (t instanceof ServiceDownException || t instanceof GitHubServiceDownException) {
errorMessage
.append("››› GitHub APIs are not available at the moment. Have a look at https://www.githubstatus.com.\n");
}
if (gitHubEvent.getRepository().isPresent()) {
errorMessage.append("› Repository: " + gitHubEvent.getRepository().get() + "\n");
errorMessage.append("› Repository: {").append(errorMessageParameters.size()).append("}\n");
errorMessageParameters.add(gitHubEvent.getRepository().get());
}
errorMessage.append("› Event: " + gitHubEvent.getEventAction() + "\n");
errorMessage.append("› Event: {").append(errorMessageParameters.size()).append("}\n");
errorMessageParameters.add(gitHubEvent.getEventAction());

if (payload != null) {
Optional<String> context = PayloadHelper.getContext(payload);
if (context.isPresent()) {
errorMessage.append("› Context: " + PayloadHelper.getContext(payload).get() + "\n");
errorMessage.append("› Context: {").append(errorMessageParameters.size()).append("}\n");
errorMessageParameters.add(context.get());
}
}

if (gitHubEvent.getAppName().isPresent()) {
errorMessage.append("› Redeliver: " + String.format(REDELIVERY_URL, gitHubEvent.getAppName().get()) + "\n");
errorMessage.append("› Redeliver: {").append(errorMessageParameters.size()).append("}\n");
errorMessageParameters.add(String.format(REDELIVERY_URL, gitHubEvent.getAppName().get()));
}

if (launchMode.isDevOrTest()) {
errorMessage.append("› Payload:\n")
.append("----\n")
.append(gitHubEvent.getParsedPayload().encodePrettily()).append("\n")
.append("{").append(errorMessageParameters.size()).append("}\n")
.append("----\n");
errorMessageParameters.add(gitHubEvent.getParsedPayload().encodePrettily());
}

errorMessage.append("Exception");

LOG.error(errorMessage.toString(), t);
LOG.errorv(t, errorMessage.toString(), errorMessageParameters.toArray());
}

}
Loading