Skip to content

Commit 869dce0

Browse files
authored
Merge pull request #33 from thescouser89/modules
Switch dingrogu to use modules
2 parents d111aaa + 8f4504c commit 869dce0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+673
-1034
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ nb-configuration.xml
4040
.env
4141

4242
# Ignore auto-generated java code
43-
/src/main/java/org/jboss/pnc/dingrogu/Constants.java
43+
/common/src/main/java/org/jboss/pnc/dingrogu/common/Constants.java

README.md

+27-41
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
11
# dingrogu
22

3-
The application configures workflows to run on [Rex](https://github.com/project-ncl/rex). A particular workflow can consists of multiple Rex tasks interlinked together.
3+
The application configures workflows to run on [Rex](https://github.com/project-ncl/rex). A particular workflow can consists of multiple Rex tasks interlinked together. Those Rex tasks will then coordinate with our services via this application's `adapter` endpoints. The latter acts as the bridge between the Rex world (generic task coordinator) and PNC services.
44

55
We want to have workflows for:
66
- repository creation (talking with [Repour](https://github.com/project-ncl/repour))
77
- milestone release
88
- build process
9+
- deliverables-analysis
10+
11+
## Packaging and Running the application
12+
13+
You can run your application using:
14+
```shell script
15+
./mvnw clean install -DskipTests=true
16+
java -jar application/target/dingrogu-runner.jar
17+
```
18+
19+
# House Rules
20+
- We only use Jackson for JSON serialization
921

1022
# Architecture
1123
This application consists of 2 parts:
12-
- The creation of the workflow to send to Rex
13-
- An adapter part that translates Rex's `StartRequest` and `StopRequest` DTOs to the specific application (if necessary)
24+
- The creation of the workflow to send to Rex (`rest-workflow` module)
25+
- An adapter part that translates Rex's `StartRequest` and `StopRequest` DTOs to the specific application, as well as
26+
handling of callbacks from the applications back to Rex
1427

15-
The adapter part might be necessary to not couple Rex's particular DTO requests with the specific downstream's
28+
The adapter part is necessary to decouple Rex's particular DTO requests with the specific downstream's
1629
application API.
1730

1831
The project is configured to build a uber-jar by default.
1932

33+
- `api` module holds any DTOs and REST interfaces that could be used to generate both client and server code
34+
- `common` module holds any code that can be shared with different modules
35+
- `rest-adapter` and `rest-workflow` modules are the REST server code that implements the REST interface.
36+
- `application` module combines all the modules together to form the final Quarkus runner jar
37+
2038
## Workflow Creation
2139
Rex requires that we specify for each task:
2240
- an endpoint to start the request and its payload
23-
- and endpoint to cancel the request and its payload
41+
- an endpoint to cancel the request and its payload
2442
- mdc values
2543

2644
Rex then sends to the endpoint the `StartRequest` DTO which contains:
@@ -51,39 +69,7 @@ graph TD
5169
Rex -->|StartRequest| GroguAdapterService2(Grogu Adapter Endpoint Service 2)
5270
GroguAdapterService2 -->|Service 2 Body| ActualService2(Actual Service 2 API)
5371
```
54-
55-
## Running the application in dev mode
56-
57-
You can run your application in dev mode that enables live coding using:
58-
```shell script
59-
./mvnw compile quarkus:dev
60-
```
61-
62-
> **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.
63-
64-
## Packaging and running the application
65-
66-
The application can be packaged using:
67-
```shell script
68-
./mvnw package
69-
```
70-
71-
## Creating a native executable
72-
73-
You can create a native executable using:
74-
```shell script
75-
./mvnw package -Pnative
76-
```
77-
78-
Or, if you don't have GraalVM installed, you can run the native executable build in a container using:
79-
```shell script
80-
./mvnw package -Pnative -Dquarkus.native.container-build=true
81-
```
82-
83-
You can then execute your native executable with: `./target/dingrogu-1.0.0-SNAPSHOT-runner`
84-
85-
If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.
86-
87-
# House Rules
88-
89-
- We only use Jackson for JSON serialization
72+
## Future Rex features to explore
73+
- Unique queue per workflow to have QoS and its own queue size
74+
- Atomic running of group of tasks; if there's a failure, the group of tasks are run again
75+
- Query Rex for the current state of affairs to get previous run data

api/pom.xml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>org.jboss.pnc.dingrogu</groupId>
7+
<artifactId>parent</artifactId>
8+
<version>0.1.2-SNAPSHOT</version>
9+
</parent>
10+
11+
<artifactId>api</artifactId>
12+
13+
<dependencies>
14+
<dependency>
15+
<groupId>org.jboss.pnc.dingrogu</groupId>
16+
<artifactId>common</artifactId>
17+
</dependency>
18+
<dependency>
19+
<groupId>io.quarkus</groupId>
20+
<artifactId>quarkus-arc</artifactId>
21+
</dependency>
22+
<dependency>
23+
<groupId>io.quarkus</groupId>
24+
<artifactId>quarkus-rest-client-jackson</artifactId>
25+
</dependency>
26+
<dependency>
27+
<groupId>io.quarkus</groupId>
28+
<artifactId>quarkus-oidc-client</artifactId>
29+
</dependency>
30+
<dependency>
31+
<groupId>io.quarkus</groupId>
32+
<artifactId>quarkus-junit5</artifactId>
33+
<scope>test</scope>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.jboss.pnc.rex</groupId>
37+
<artifactId>rex-api</artifactId>
38+
</dependency>
39+
<dependency>
40+
<groupId>org.jboss.pnc.rex</groupId>
41+
<artifactId>rex-model</artifactId>
42+
</dependency>
43+
<dependency>
44+
<groupId>org.jboss.pnc</groupId>
45+
<artifactId>pnc-api</artifactId>
46+
<classifier>jakarta</classifier>
47+
</dependency>
48+
<dependency>
49+
<groupId>com.squareup.retrofit2</groupId>
50+
<artifactId>retrofit</artifactId>
51+
</dependency>
52+
<dependency>
53+
<groupId>com.squareup.retrofit2</groupId>
54+
<artifactId>converter-jackson</artifactId>
55+
</dependency>
56+
<dependency>
57+
<groupId>org.projectlombok</groupId>
58+
<artifactId>lombok</artifactId>
59+
<scope>provided</scope>
60+
</dependency>
61+
</dependencies>
62+
</project>

src/main/java/org/jboss/pnc/dingrogu/client/RepourClient.java api/src/main/java/org/jboss/pnc/dingrogu/api/client/RepourClient.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
package org.jboss.pnc.dingrogu.client;
1+
package org.jboss.pnc.dingrogu.api.client;
22

33
import jakarta.ws.rs.POST;
44
import jakarta.ws.rs.Path;
55
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
66
import org.jboss.pnc.api.repour.dto.RepourCloneRepositoryRequest;
77
import org.jboss.pnc.api.repour.dto.RepourCreateRepositoryRequest;
8-
import org.jboss.pnc.dingrogu.dto.RepourCloneResponse;
9-
import org.jboss.pnc.dingrogu.dto.RepourCreateRepositoryResponse;
8+
import org.jboss.pnc.dingrogu.api.dto.RepourCloneResponse;
9+
import org.jboss.pnc.dingrogu.api.dto.RepourCreateRepositoryResponse;
1010

1111
@Path("/")
1212
@RegisterRestClient

src/main/java/org/jboss/pnc/dingrogu/client/RexClient.java api/src/main/java/org/jboss/pnc/dingrogu/api/client/RexClient.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
package org.jboss.pnc.dingrogu.client;
1+
package org.jboss.pnc.dingrogu.api.client;
22

33
import com.fasterxml.jackson.databind.ObjectMapper;
44
import io.quarkus.logging.Log;
5-
import io.quarkus.oidc.client.Tokens;
65
import jakarta.enterprise.context.ApplicationScoped;
76
import jakarta.enterprise.inject.Produces;
87
import jakarta.inject.Inject;
@@ -24,8 +23,8 @@ public class RexClient {
2423
@Inject
2524
ObjectMapper objectMapper;
2625

27-
@Inject
28-
Tokens token;
26+
// @Inject
27+
// Tokens token;
2928

3029
@Produces
3130
public TaskEndpoint getRexTaskEndpoint() {
@@ -39,7 +38,7 @@ public void invokeCallback(org.jboss.pnc.api.dto.Request callback, FinishRequest
3938
RequestBody requestBody = RequestBody.create(json, objectMapper.writeValueAsString(finishRequest));
4039
Request request = new Request.Builder().url(callback.getUri().toURL())
4140
.post(requestBody)
42-
.addHeader("Authentication", "Bearer " + token.getAccessToken())
41+
// .addHeader("Authentication", "Bearer " + token.getAccessToken())
4342
.build();
4443

4544
try (Response response = CLIENT.newCall(request).execute()) {

src/main/java/org/jboss/pnc/dingrogu/dto/MilestoneReleaseDTO.java api/src/main/java/org/jboss/pnc/dingrogu/api/dto/MilestoneReleaseDTO.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.jboss.pnc.dingrogu.dto;
1+
package org.jboss.pnc.dingrogu.api.dto;
22

33
import lombok.Builder;
44
import lombok.Data;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package org.jboss.pnc.dingrogu.api.dto;
2+
3+
public class RepourCloneResponse {
4+
}

src/main/java/org/jboss/pnc/dingrogu/dto/RepourCreateRepositoryResponse.java api/src/main/java/org/jboss/pnc/dingrogu/api/dto/RepourCreateRepositoryResponse.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.jboss.pnc.dingrogu.dto;
1+
package org.jboss.pnc.dingrogu.api.dto;
22

33
import com.fasterxml.jackson.annotation.JsonProperty;
44
import lombok.Builder;

src/main/java/org/jboss/pnc/dingrogu/dto/RepourCreateRepositoryStatus.java api/src/main/java/org/jboss/pnc/dingrogu/api/dto/RepourCreateRepositoryStatus.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.jboss.pnc.dingrogu.dto;
1+
package org.jboss.pnc.dingrogu.api.dto;
22

33
public enum RepourCreateRepositoryStatus {
44
SUCCESS_CREATED, SUCCESS_ALREADY_EXISTS, FAILURE

src/main/java/org/jboss/pnc/dingrogu/dto/adapter/RepourCloneRepositoryDTO.java api/src/main/java/org/jboss/pnc/dingrogu/api/dto/adapter/RepourCloneRepositoryDTO.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.jboss.pnc.dingrogu.dto.adapter;
1+
package org.jboss.pnc.dingrogu.api.dto.adapter;
22

33
import lombok.Builder;
44
import lombok.Data;

src/main/java/org/jboss/pnc/dingrogu/dto/adapter/RepourCreateRepositoryDTO.java api/src/main/java/org/jboss/pnc/dingrogu/api/dto/adapter/RepourCreateRepositoryDTO.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.jboss.pnc.dingrogu.dto.adapter;
1+
package org.jboss.pnc.dingrogu.api.dto.adapter;
22

33
import lombok.Builder;
44
import lombok.Data;

api/src/main/resources/META-INF/beans.xml

Whitespace-only changes.

application/pom.xml

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?xml version="1.0"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>org.jboss.pnc.dingrogu</groupId>
7+
<artifactId>parent</artifactId>
8+
<version>0.1.2-SNAPSHOT</version>
9+
</parent>
10+
11+
<artifactId>application</artifactId>
12+
<dependencies>
13+
<dependency>
14+
<groupId>io.quarkus</groupId>
15+
<artifactId>quarkus-arc</artifactId>
16+
</dependency>
17+
<dependency>
18+
<groupId>org.jboss.pnc.dingrogu</groupId>
19+
<artifactId>api</artifactId>
20+
</dependency>
21+
<dependency>
22+
<groupId>org.jboss.pnc.dingrogu</groupId>
23+
<artifactId>common</artifactId>
24+
</dependency>
25+
<dependency>
26+
<groupId>org.jboss.pnc.dingrogu</groupId>
27+
<artifactId>rest-workflow</artifactId>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.jboss.pnc.dingrogu</groupId>
31+
<artifactId>rest-adapter</artifactId>
32+
</dependency>
33+
</dependencies>
34+
35+
<build>
36+
<plugins>
37+
<plugin>
38+
<groupId>${quarkus.platform.group-id}</groupId>
39+
<artifactId>quarkus-maven-plugin</artifactId>
40+
<version>${quarkus.platform.version}</version>
41+
<extensions>true</extensions>
42+
<executions>
43+
<execution>
44+
<goals>
45+
<goal>build</goal>
46+
<goal>generate-code</goal>
47+
<goal>generate-code-tests</goal>
48+
</goals>
49+
</execution>
50+
</executions>
51+
<configuration>
52+
<finalName>dingrogu</finalName>
53+
</configuration>
54+
</plugin>
55+
<plugin>
56+
<artifactId>maven-compiler-plugin</artifactId>
57+
<version>${compiler-plugin.version}</version>
58+
<configuration>
59+
<compilerArgs>
60+
<arg>-parameters</arg>
61+
</compilerArgs>
62+
</configuration>
63+
</plugin>
64+
<plugin>
65+
<artifactId>maven-surefire-plugin</artifactId>
66+
<version>${surefire-plugin.version}</version>
67+
<configuration>
68+
<systemPropertyVariables>
69+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
70+
<maven.home>${maven.home}</maven.home>
71+
</systemPropertyVariables>
72+
</configuration>
73+
</plugin>
74+
<plugin>
75+
<artifactId>maven-failsafe-plugin</artifactId>
76+
<version>${surefire-plugin.version}</version>
77+
<executions>
78+
<execution>
79+
<goals>
80+
<goal>integration-test</goal>
81+
<goal>verify</goal>
82+
</goals>
83+
<configuration>
84+
<systemPropertyVariables>
85+
<native.image.path>${project.build.directory}/${project.build.finalName}-runner
86+
</native.image.path>
87+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
88+
<maven.home>${maven.home}</maven.home>
89+
</systemPropertyVariables>
90+
</configuration>
91+
</execution>
92+
</executions>
93+
</plugin>
94+
</plugins>
95+
</build>
96+
</project>

application/src/main/resources/META-INF/beans.xml

Whitespace-only changes.

src/main/resources/application.yaml application/src/main/resources/application.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ dingrogu:
44
rexclient:
55
url: http://rex-newcastle-devel.apps.ocp-c1.prod.psi.redhat.com
66
quarkus:
7+
oidc:
8+
enabled: false
79
oidc-client:
10+
enabled: false
811
auth-server-url: http://localhost:8180/auth/realms/quarkus
912
client-id: dustin
1013
credentials:
11-
secret: 1234
14+
secret: 1234

0 commit comments

Comments
 (0)