From 87f45b8329d6611e370393972909992bed0cbc59 Mon Sep 17 00:00:00 2001 From: Jonathan Christison Date: Wed, 5 Jul 2023 23:21:36 +0100 Subject: [PATCH] Give up on using PNC rest client for now roll our own There is incompatibility between resteasy in quarkus (6.x) to the one used in PNC (3.x), the API design has changed quite a bit and it seems impossible to have both exist on the classpath at the same time. For the one endpoint we need (Build) then our own restclient should do --- pom.xml | 33 ++----------------- .../com/redhat/pctsec/model/PNCBuild.java | 16 +++++++-- .../model/api/service/AltPncService.java | 12 +++++++ 3 files changed, 29 insertions(+), 32 deletions(-) create mode 100644 src/main/java/com/redhat/pctsec/model/api/service/AltPncService.java diff --git a/pom.xml b/pom.xml index 090d0f1..83453dc 100644 --- a/pom.xml +++ b/pom.xml @@ -96,42 +96,15 @@ org.jboss.pnc rest-client 2.5.1 - - - - - - - org.glassfish.jersey.core - jersey-client - 2.34 + io.quarkus + quarkus-rest-client-reactive - - io.quarkus quarkus-junit5 diff --git a/src/main/java/com/redhat/pctsec/model/PNCBuild.java b/src/main/java/com/redhat/pctsec/model/PNCBuild.java index eb8c695..a6f2f88 100644 --- a/src/main/java/com/redhat/pctsec/model/PNCBuild.java +++ b/src/main/java/com/redhat/pctsec/model/PNCBuild.java @@ -1,9 +1,14 @@ package com.redhat.pctsec.model; -import com.redhat.pctsec.model.api.service.PncService; +import com.redhat.pctsec.model.api.service.AltPncService; +//import com.redhat.pctsec.model.api.service.PncService; +import io.quarkus.rest.client.reactive.QuarkusRestClientBuilder; +import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import jakarta.persistence.Entity; import jakarta.persistence.Transient; +import org.eclipse.microprofile.config.ConfigProvider; +import org.eclipse.microprofile.config.inject.ConfigProperty; import org.jboss.pnc.dto.Build; import java.net.URI; @@ -13,8 +18,16 @@ import java.net.URL; public class PNCBuild extends BuildType{ + @Transient + public static final String apiUrl = ConfigProvider.getConfig().getValue("pnc.api-url",String.class); + @Transient + private static final AltPncService pnc = QuarkusRestClientBuilder.newBuilder().baseUri(URI.create(apiUrl)).build(AltPncService.class); + + + /* @Transient PncService pnc; + */ @Transient Build build; @@ -33,7 +46,6 @@ public class PNCBuild extends BuildType{ public PNCBuild(String buildRef) { super(buildRef); - this.pnc = new PncService(); } @Override diff --git a/src/main/java/com/redhat/pctsec/model/api/service/AltPncService.java b/src/main/java/com/redhat/pctsec/model/api/service/AltPncService.java new file mode 100644 index 0000000..2f09a58 --- /dev/null +++ b/src/main/java/com/redhat/pctsec/model/api/service/AltPncService.java @@ -0,0 +1,12 @@ +package com.redhat.pctsec.model.api.service; +import jakarta.ws.rs.*; +import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; +import org.jboss.pnc.dto.Build; + +@Path("pnc-rest/v2/builds") +@RegisterRestClient +public interface AltPncService { + @GET + @Path("{id}") + Build getBuild(@PathParam("id") String id); +}