From e8d01029a344fec1e8dce621631ea7930e03768d Mon Sep 17 00:00:00 2001 From: Nick Cross Date: Thu, 5 Dec 2024 11:46:59 +0000 Subject: [PATCH 1/2] Correct pom/gh-actions. Add Indy clients --- .github/workflows/maven.yml | 4 +-- pom.xml | 30 ++++++++++++++--- .../clients/IndyService.java | 33 +++++++++++++++++++ .../clients/IndyTokenRequestDTO.java | 12 +++++++ .../clients/IndyTokenResponseDTO.java | 11 +++++++ 5 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 src/main/java/org/jboss/pnc/konfluxbuilddriver/clients/IndyService.java create mode 100644 src/main/java/org/jboss/pnc/konfluxbuilddriver/clients/IndyTokenRequestDTO.java create mode 100644 src/main/java/org/jboss/pnc/konfluxbuilddriver/clients/IndyTokenResponseDTO.java diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 01c6ae5..f019766 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -18,7 +18,7 @@ on: jobs: build: # https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idif - # if: github.repository == 'pnc/konflux-build-konflux-build-driver' && github.event_name == 'pull_request' + if: github.repository == 'project-ncl/konflux-build-driver' && github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -47,7 +47,7 @@ jobs: verbose: true snapshot: - if: github.repository == 'pnc/konflux-build-konflux-build-driver' && github.event_name == 'push' && github.ref == 'refs/heads/main' + if: github.repository == 'project-ncl/konflux-build-driver' && github.event_name == 'push' && github.ref == 'refs/heads/main' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/pom.xml b/pom.xml index 830efab..6318970 100644 --- a/pom.xml +++ b/pom.xml @@ -14,11 +14,11 @@ Konflux Build Driver PNC Build Driver for Konflux - https://github.com/pnc/konflux-build-driver + https://github.com/project-ncl/konflux-build-driver - scm:git:https://github.com/pnc/konflux-build-driver.git - scm:git:git@github.com:pnc/konflux-build-driver.git - https://github.com/pnc/konflux-build-driver + scm:git:https://github.com/project-ncl/konflux-build-driver.git + scm:git:git@github.com:project-ncl/konflux-build-driver.git + https://github.com/project-ncl/konflux-build-driver HEAD @@ -46,6 +46,8 @@ quarkus-bom io.quarkus.platform 3.17.3 + + 1.18.32 @@ -61,6 +63,26 @@ + + io.quarkus + quarkus-oidc + + + io.quarkus + quarkus-oidc-client + + + io.quarkus + quarkus-rest-client-jackson + + + + org.projectlombok + lombok + ${version.lombok} + provided + + io.quarkus quarkus-junit5 diff --git a/src/main/java/org/jboss/pnc/konfluxbuilddriver/clients/IndyService.java b/src/main/java/org/jboss/pnc/konfluxbuilddriver/clients/IndyService.java new file mode 100644 index 0000000..0b4f9d3 --- /dev/null +++ b/src/main/java/org/jboss/pnc/konfluxbuilddriver/clients/IndyService.java @@ -0,0 +1,33 @@ +package org.jboss.pnc.konfluxbuilddriver.clients; + +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.HeaderParam; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; + +/** + * Indy service representing the Indy server. It uses Quarkus magical rest client to generate the client implementation + */ +@RegisterRestClient(configKey = "indy-service") +public interface IndyService { + + /** + * Ask Indy to give us the token that we will use for Maven communication with Indy, in the builder pod for the + * particular buildId + * + * @param indyTokenRequestDTO the DTO to send to Indy + * @param accessToken accessToken required to send data. Note that it should include "Bearer " + * + * @return Token DTO + */ + @Path("/api/security/auth/token") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + @POST + IndyTokenResponseDTO getAuthToken( + IndyTokenRequestDTO indyTokenRequestDTO, + @HeaderParam("Authorization") String accessToken); +} diff --git a/src/main/java/org/jboss/pnc/konfluxbuilddriver/clients/IndyTokenRequestDTO.java b/src/main/java/org/jboss/pnc/konfluxbuilddriver/clients/IndyTokenRequestDTO.java new file mode 100644 index 0000000..10c954e --- /dev/null +++ b/src/main/java/org/jboss/pnc/konfluxbuilddriver/clients/IndyTokenRequestDTO.java @@ -0,0 +1,12 @@ +package org.jboss.pnc.konfluxbuilddriver.clients; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Builder; + +/** + * DTO of the Indy token endpoint request + */ +@Builder +public record IndyTokenRequestDTO(@JsonProperty("build-id") String buildId) { + +} diff --git a/src/main/java/org/jboss/pnc/konfluxbuilddriver/clients/IndyTokenResponseDTO.java b/src/main/java/org/jboss/pnc/konfluxbuilddriver/clients/IndyTokenResponseDTO.java new file mode 100644 index 0000000..09ada90 --- /dev/null +++ b/src/main/java/org/jboss/pnc/konfluxbuilddriver/clients/IndyTokenResponseDTO.java @@ -0,0 +1,11 @@ +package org.jboss.pnc.konfluxbuilddriver.clients; + +import lombok.Builder; + +/** + * DTO of the Indy token endpoint response + */ +@Builder +public record IndyTokenResponseDTO(String token) { + +} From aefff1420cb9f1c603d57a12a211b4c3feb0cb9f Mon Sep 17 00:00:00 2001 From: Nick Cross Date: Thu, 5 Dec 2024 14:10:38 +0000 Subject: [PATCH 2/2] Release configuration. Add impsort/formatter. --- .github/workflows/maven.yml | 4 ++-- pom.xml | 47 +++++++++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index f019766..346164f 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -65,7 +65,7 @@ jobs: java-version: 21 # https://github.com/marketplace/actions/maven-setings-action - name: Maven Settings - uses: s4u/maven-settings-action@v3.0.0 + uses: s4u/maven-settings-action@v3.1.0 with: sonatypeSnapshots: true githubServer: false @@ -76,4 +76,4 @@ jobs: "password": "${{ secrets.SONATYPE_PASSWORD }}" }] - name: Deploy Snapshot - run: mvn -B -V org.apache.maven.plugins:maven-source-plugin:jar-no-fork deploy + run: mvn -B -V -Pjboss-release org.apache.maven.plugins:maven-source-plugin:jar-no-fork deploy diff --git a/pom.xml b/pom.xml index 6318970..d132849 100644 --- a/pom.xml +++ b/pom.xml @@ -43,11 +43,21 @@ UTF-8 UTF-8 + + sonatype-nexus-staging + https://oss.sonatype.org/service/local/staging/deploy/maven2 + sonatype-nexus-snapshots + https://oss.sonatype.org/content/repositories/snapshots + quarkus-bom io.quarkus.platform 3.17.3 - 1.18.32 + 1.18.32 + 2.24.1 + 1.12.0 + + false @@ -79,7 +89,7 @@ org.projectlombok lombok - ${version.lombok} + ${lombok.version} provided @@ -112,6 +122,39 @@ + + net.revelc.code.formatter + formatter-maven-plugin + ${formatter-maven-plugin.version} + + + io.quarkus + quarkus-ide-config + ${quarkus.platform.version} + + + + + .cache/formatter-maven-plugin-${formatter-maven-plugin.version} + eclipse-format.xml + LF + ${format.skip} + + + + net.revelc.code + impsort-maven-plugin + ${impsort-maven-plugin.version} + + + .cache/impsort-maven-plugin-${impsort-maven-plugin.version} + java.,javax.,jakarta.,org.,com. + * + LF + ${format.skip} + true + + maven-surefire-plugin