Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: scratch analysis without milestone #1092

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.util.List;

import jakarta.validation.constraints.Size;
import org.jboss.sbomer.core.features.sbom.config.runtime.ErrataConfig;

import com.fasterxml.jackson.annotation.JsonIgnore;
Expand All @@ -32,6 +33,7 @@
import lombok.experimental.SuperBuilder;
import lombok.extern.jackson.Jacksonized;


/**
* SBOMer configuration file to trigger a new PNC deliverable analysis.
*
Expand Down Expand Up @@ -60,6 +62,7 @@ public class DeliverableAnalysisConfig extends Config {
/**
* Deliverables entries for the given operation.
*/
@Size(min = 1)
List<String> deliverableUrls;

@JsonIgnore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.eclipse.microprofile.rest.client.inject.RestClient;
import org.jboss.pnc.dto.DeliverableAnalyzerOperation;
import org.jboss.pnc.dto.requests.DeliverablesAnalysisRequest;
import org.jboss.pnc.dto.requests.ScratchDeliverablesAnalysisRequest;
import org.jboss.sbomer.core.SchemaValidator.ValidationResult;
import org.jboss.sbomer.core.config.ConfigSchemaValidator;
import org.jboss.sbomer.core.config.SbomerConfigProvider;
Expand Down Expand Up @@ -588,9 +589,14 @@ public V1Beta1RequestRecord searchLastSuccessfulAdvisoryRequestRecord(String ign

public DeliverableAnalyzerOperation doAnalyzeDeliverables(DeliverableAnalysisConfig config) {
try {
return pncClient.analyzeDeliverables(
config.getMilestoneId(),
DeliverablesAnalysisRequest.builder().deliverablesUrls(config.getDeliverableUrls()).build());
if (config.getMilestoneId() == null) {
return pncClient.startScratchDeliverableAnalysis(
ScratchDeliverablesAnalysisRequest.builder().deliverablesUrls(config.getDeliverableUrls()).build());
} else {
return pncClient.analyzeDeliverables(
config.getMilestoneId(),
DeliverablesAnalysisRequest.builder().deliverablesUrls(config.getDeliverableUrls()).build());
}
} catch (ClientException ex) {
throw new ApplicationException("Operation could not be retrieved because PNC responded with an error", ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.jboss.pnc.dto.requests.ScratchDeliverablesAnalysisRequest;

@ApplicationScoped
@ClientHeaderParam(name = "User-Agent", value = "SBOMer")
Expand All @@ -51,4 +52,9 @@ DeliverableAnalyzerOperation analyzeDeliverables(
@Path("/operations/deliverable-analyzer/{id}")
DeliverableAnalyzerOperation getDeliverableAnalyzerOperation(@PathParam("id") String operationId);

@POST
@Path("/operations/deliverable-analyzer/start")
DeliverableAnalyzerOperation startScratchDeliverableAnalysis(
ScratchDeliverablesAnalysisRequest scratchDeliverablesAnalysisRequest);

}
Loading