Skip to content

Commit

Permalink
Merge pull request #7 from rnc/NOTIFY
Browse files Browse the repository at this point in the history
Allow notifications to be configurable
  • Loading branch information
rnc authored Dec 19, 2024
2 parents 26ff0cc + 6b7962c commit 69fe9b1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/main/java/org/jboss/pnc/konfluxbuilddriver/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,21 @@ public BuildResponse create(BuildRequest buildRequest) {
// TODO: This should be changed to true eventually.
templateProperties.put("ENABLE_INDY_PROXY", config.indyProxyEnabled());

try {
Request notificationCallback = new Request(
Request.Method.PUT,
new URI(StringUtils.appendIfMissing(config.selfBaseUrl(), "/") + "internal/completed"),
Collections.singletonList(new Request.Header(HttpHeaders.CONTENT_TYPE_STRING, MediaType.APPLICATION_JSON)),
buildRequest.completionCallback());

templateProperties.put("NOTIFICATION_CONTEXT", objectMapper.writeValueAsString(notificationCallback));
} catch (JsonProcessingException | URISyntaxException e) {
throw new RuntimeException(e);
if (config.notificationEnabled()) {
try {
Request notificationCallback = new Request(
Request.Method.PUT,
new URI(StringUtils.appendIfMissing(config.selfBaseUrl(), "/") + "internal/completed"),
Collections.singletonList(
new Request.Header(HttpHeaders.CONTENT_TYPE_STRING, MediaType.APPLICATION_JSON)),
buildRequest.completionCallback());

templateProperties.put("NOTIFICATION_CONTEXT", objectMapper.writeValueAsString(notificationCallback));
} catch (JsonProcessingException | URISyntaxException e) {
throw new RuntimeException(e);
}
} else {
templateProperties.put("NOTIFICATION_CONTEXT", "");
}

// Various ways to create the initial PipelineRun object. We can use an objectmapper,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ public interface Configuration {
String indyProxyEnabled();

String selfBaseUrl();

Boolean notificationEnabled();
}
1 change: 1 addition & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ konflux-build-driver:
# TODO: This will eventually be build-definitions repository
pipeline-resolver: "https://raw.githubusercontent.com/redhat-appstudio/jvm-build-service/refs/heads/main/deploy/pipeline/mw-pipeline-v0.1.yaml"
indy-proxy-enabled: false
notification-enabled: false
self-base-url: http://localhost:8081/
quarkus:
application:
Expand Down

0 comments on commit 69fe9b1

Please sign in to comment.