Skip to content

Commit

Permalink
[NCL-8963] Driver code for deliverables-analyzer dingrogu
Browse files Browse the repository at this point in the history
  • Loading branch information
thescouser89 committed Jan 30, 2025
1 parent db665ef commit 7bf163f
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
4 changes: 4 additions & 0 deletions dingrogu-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
<groupId>org.jboss.pnc</groupId>
<artifactId>spi</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.pnc</groupId>
<artifactId>auth</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import org.jboss.pnc.api.dto.Request;
import org.jboss.pnc.api.enums.BuildCategory;
import org.jboss.pnc.api.enums.BuildType;
import org.jboss.pnc.auth.KeycloakServiceClient;
import org.jboss.pnc.common.json.GlobalModuleGroup;
import org.jboss.pnc.common.util.HttpUtils;
import org.jboss.pnc.model.utils.ContentIdentityManager;
import org.jboss.pnc.spi.coordinator.RemoteBuildTask;

Expand All @@ -30,14 +32,21 @@
import java.net.URI;
import java.util.List;
import java.util.Map;
import java.util.Optional;

@ApplicationScoped
public class DingroguClient {

@Inject
private GlobalModuleGroup global;

public Request startProcessInstance(RemoteBuildTask buildTask, List<Request.Header> headers, String correlationId) {
@Inject
private KeycloakServiceClient keycloakServiceClient;

public Request startBuildProcessInstance(
RemoteBuildTask buildTask,
List<Request.Header> headers,
String correlationId) {
DingroguBuildWorkDTO dto = createDTO(buildTask, correlationId);
return new Request(
Request.Method.POST,
Expand All @@ -46,6 +55,14 @@ public Request startProcessInstance(RemoteBuildTask buildTask, List<Request.Head
dto);
}

public void submitDeliverablesAnalysis(DingroguDeliverablesAnalysisDTO dto) {
String url = global.getExternalDingroguUrl() + "/workflow/deliverables-analysis/start";
HttpUtils.performHttpRequest(
Request.builder().method(Request.Method.POST).uri(URI.create(url)).build(),
dto,
Optional.of(keycloakServiceClient.getAuthToken()));
}

public Request cancelProcessInstance(List<Request.Header> headers, String correlationId) {

return new Request(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* JBoss, Home of Professional Open Source.
* Copyright 2014-2022 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.pnc.dingroguclient;

import lombok.Builder;
import lombok.Data;
import lombok.extern.jackson.Jacksonized;
import org.jboss.pnc.api.dto.Request;

import java.util.List;

@Jacksonized
@Data
@Builder
public class DingroguDeliverablesAnalysisDTO {
String deliverablesAnalyzerUrl;
String orchUrl;

List<String> urls;
String config;
boolean scratch;

String operationId;
// callback for operationId
Request callback;
}
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ private CreateTaskDTO getCreateNewTaskDingroguDTO(RemoteBuildTask buildTask) {
new Request.Header(HttpHeaders.ACCEPT_STRING, MediaType.APPLICATION_JSON)));

String correlationId = UUID.randomUUID().toString();
Request remoteStart = dingroguClient.startProcessInstance(buildTask, headers, correlationId);
Request remoteStart = dingroguClient.startBuildProcessInstance(buildTask, headers, correlationId);
Request remoteCancel = dingroguClient.cancelProcessInstance(headers, correlationId);

BuildMeta buildMetadata = mappers.toBuildMeta(buildTask);
Expand Down

0 comments on commit 7bf163f

Please sign in to comment.