From dfa48cfe9821634ae7a6dc01652bc557271388b7 Mon Sep 17 00:00:00 2001 From: Jonathan Christison Date: Wed, 28 Jun 2023 09:40:56 +0100 Subject: [PATCH] Decouple ScanRequest from tekton runs We will use an eventbus to listen for "executed"/triggered ScanRequests and respond with tekton runID to check up on later --- .../redhat/pctsec/model/BrewScanRequest.java | 8 +++++ .../com/redhat/pctsec/model/ScanRequest.java | 32 ++++--------------- .../com/redhat/pctsec/model/ScanRequests.java | 2 +- 3 files changed, 15 insertions(+), 27 deletions(-) create mode 100644 src/main/java/com/redhat/pctsec/model/BrewScanRequest.java diff --git a/src/main/java/com/redhat/pctsec/model/BrewScanRequest.java b/src/main/java/com/redhat/pctsec/model/BrewScanRequest.java new file mode 100644 index 0000000..4990e12 --- /dev/null +++ b/src/main/java/com/redhat/pctsec/model/BrewScanRequest.java @@ -0,0 +1,8 @@ +package com.redhat.pctsec.model; + +public class BrewScanRequest extends ScanRequest{ + @Override + public void executeScan() { + bus.requestAndForget("tekton", this); + } +} diff --git a/src/main/java/com/redhat/pctsec/model/ScanRequest.java b/src/main/java/com/redhat/pctsec/model/ScanRequest.java index 6e2a42c..5b40be7 100644 --- a/src/main/java/com/redhat/pctsec/model/ScanRequest.java +++ b/src/main/java/com/redhat/pctsec/model/ScanRequest.java @@ -2,40 +2,20 @@ package com.redhat.pctsec.model; import com.redhat.pctsec.tekton.brewTaskRun; import com.redhat.pctsec.tekton.scmUrlPipelineRun; +import io.vertx.mutiny.core.eventbus.EventBus; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import jakarta.inject.Singleton; import java.util.HashMap; @ApplicationScoped -public class ScanRequest { - - private HashMap metadata; - private HashMap oshScanOptions; - private String brewBuild; - private HashMap scmurl; +abstract public class ScanRequest { @Inject - brewTaskRun btr; + EventBus bus; - @Inject - scmUrlPipelineRun plr; - - public ScanRequest(String brewBuildId) - { - this.brewBuild = brewBuildId; - } + private HashMap metadata; + private HashMap oshScanOptions; - public ScanRequest(String repo, String ref) - { - this.scmurl = new HashMap<>(); - this.scmurl.put("repo", repo); - this.scmurl.put("ref", repo); - } - public void executeScan(){ - if(this.brewBuild != null && !this.brewBuild.trim().isEmpty()){ - //btr = new brewTaskRun(); - btr.invokeScanTask(this.brewBuild); - } - } + public abstract void executeScan(); } diff --git a/src/main/java/com/redhat/pctsec/model/ScanRequests.java b/src/main/java/com/redhat/pctsec/model/ScanRequests.java index 185de6d..1877245 100644 --- a/src/main/java/com/redhat/pctsec/model/ScanRequests.java +++ b/src/main/java/com/redhat/pctsec/model/ScanRequests.java @@ -16,8 +16,8 @@ public class ScanRequests { private HashMap globalScanProperties; public ScanRequests(){ - this.id = } + public ScanRequests(pssaas pssaas){ //Iterate scan payload and create scans }