8 changed files with 434 additions and 136 deletions
@ -0,0 +1,20 @@
|
||||
// package rest;
|
||||
|
||||
// import java.util.List;
|
||||
|
||||
// import jakarta.enterprise.context.ApplicationScoped;
|
||||
// import io.fabric8.tekton.client.TektonClient;
|
||||
// import io.fabric8.tekton.pipeline.v1beta1.Pipeline;
|
||||
|
||||
|
||||
// @ApplicationScoped
|
||||
// public class TektonResourceClient {
|
||||
|
||||
// // @Inject
|
||||
// TektonClient tektonClient;l
|
||||
|
||||
// public List<Pipeline> listPipelines() {
|
||||
// return tektonClient.v1beta1().pipelines().list().getItems();
|
||||
// }
|
||||
|
||||
// }
|
||||
@ -0,0 +1,175 @@
|
||||
// package rest;
|
||||
|
||||
|
||||
import io.fabric8.tekton.client.DefaultTektonClient; |
||||
import io.fabric8.tekton.client.TektonClient; |
||||
|
||||
|
||||
import javax.inject.Inject; |
||||
import javax.validation.Valid; |
||||
import javax.ws.rs.Consumes; |
||||
import javax.ws.rs.POST; |
||||
import javax.ws.rs.Path; |
||||
import java.net.URI; |
||||
import java.net.URISyntaxException; |
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
import java.util.UUID; |
||||
import org.json.JSONObject; |
||||
import org.json.JSONArray; |
||||
import dto.ScanObj; |
||||
import dto.BrewObj; |
||||
import dto.ConnectDB; |
||||
import dto.ScanObjPayload; |
||||
import dto.BrewObjPayload; |
||||
import dto.GitObj; |
||||
import dto.GitObjPayload; |
||||
import dto.PncObj; |
||||
import dto.PncObjPayload; |
||||
|
||||
import static constants.HttpHeaders.AUTHORIZATION_STRING; |
||||
import java.sql.Connection; |
||||
import java.sql.DriverManager; |
||||
import java.sql.SQLException; |
||||
|
||||
import java.sql.Connection; |
||||
import java.sql.DriverManager; |
||||
import java.sql.ResultSet; |
||||
import java.sql.Statement; |
||||
|
||||
import java.util.Collections; |
||||
import java.util.LinkedHashMap; |
||||
import java.util.Set; |
||||
import dto.ScanObj; |
||||
import dto.ConnectDB; |
||||
|
||||
import java.sql.Connection; |
||||
import java.sql.DriverManager; |
||||
import java.sql.SQLException; |
||||
|
||||
import java.sql.Connection; |
||||
import java.sql.DriverManager; |
||||
import java.sql.ResultSet; |
||||
import java.sql.Statement; |
||||
|
||||
import javax.ws.rs.DELETE; |
||||
import javax.ws.rs.GET; |
||||
import javax.ws.rs.POST; |
||||
import javax.ws.rs.Path; |
||||
import javax.inject.Inject; |
||||
import javax.ws.rs.GET; |
||||
import javax.ws.rs.Path; |
||||
import javax.ws.rs.PathParam; |
||||
import java.util.Set; |
||||
import java.util.stream.Collectors; |
||||
import javax.inject.Inject; |
||||
import javax.ws.rs.Consumes; |
||||
|
||||
import java.sql.*; |
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
import com.fasterxml.jackson.databind.ObjectWriter; |
||||
|
||||
// import org.hibernate.EntityManager;
|
||||
import jakarta.persistence.EntityManager; |
||||
import jakarta.persistence.Cacheable; |
||||
import jakarta.persistence.Column; |
||||
import jakarta.persistence.Entity; |
||||
import jakarta.persistence.GeneratedValue; |
||||
import jakarta.persistence.Id; |
||||
import jakarta.persistence.NamedQuery; |
||||
import jakarta.persistence.QueryHint; |
||||
import jakarta.persistence.SequenceGenerator; |
||||
import jakarta.persistence.Table; |
||||
|
||||
|
||||
import io.fabric8.tekton.client.DefaultTektonClient; |
||||
import io.fabric8.tekton.client.TektonClient; |
||||
import io.fabric8.tekton.pipeline.v1beta1.TaskBuilder; |
||||
import io.fabric8.tekton.pipeline.v1beta1.Task; |
||||
|
||||
import org.eclipse.microprofile.rest.client.inject.RestClient; |
||||
import dto.ScanObj; |
||||
|
||||
import javax.inject.Inject; |
||||
import javax.validation.Valid; |
||||
import javax.ws.rs.Consumes; |
||||
import javax.ws.rs.POST; |
||||
import javax.ws.rs.Path; |
||||
import java.net.URI; |
||||
import java.net.URISyntaxException; |
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
import java.util.UUID; |
||||
import org.json.JSONObject; |
||||
import org.json.JSONArray; |
||||
import dto.ScanObj; |
||||
import dto.BrewObj; |
||||
import dto.ConnectDB; |
||||
import dto.ScanObjPayload; |
||||
import dto.BrewObjPayload; |
||||
import dto.GitObj; |
||||
import dto.GitObjPayload; |
||||
import dto.PncObj; |
||||
import dto.PncObjPayload; |
||||
|
||||
import static constants.HttpHeaders.AUTHORIZATION_STRING; |
||||
import java.sql.Connection; |
||||
import java.sql.DriverManager; |
||||
import java.sql.SQLException; |
||||
|
||||
import java.sql.Connection; |
||||
import java.sql.DriverManager; |
||||
import java.sql.ResultSet; |
||||
import java.sql.Statement; |
||||
|
||||
import io.fabric8.tekton.client.DefaultTektonClient; |
||||
import io.fabric8.tekton.client.TektonClient; |
||||
import io.fabric8.tekton.pipeline.v1beta1.TaskBuilder; |
||||
import io.fabric8.tekton.pipeline.v1beta1.TaskRunBuilder; |
||||
|
||||
|
||||
@Path("/tekton") |
||||
public class TektonTaskCreate { |
||||
|
||||
@RestClient |
||||
|
||||
private static final String NAMESPACE = "default"; |
||||
|
||||
@POST |
||||
@Consumes({ "application/json" }) |
||||
public void invokeTektonTask(String data) { |
||||
JSONObject jsonData = new JSONObject(data); |
||||
// ScanObj scanObj = ScanObjPayload.constructScanPayload(jsonData);
|
||||
|
||||
//dont leave this in live needs to be adjusted (currently would cause a ton of issues)
|
||||
String tektonArgs = "osh-cli mock-build --config="+jsonData.get("config")+"--brew-build"+jsonData.get("nvr"); |
||||
|
||||
try (TektonClient tkn = new DefaultTektonClient()) { |
||||
// Create Task
|
||||
tkn.v1beta1().tasks().inNamespace(NAMESPACE).resource(new TaskBuilder() |
||||
.withNewMetadata().withName("tekton-osh-client").endMetadata() |
||||
.withNewSpec() |
||||
.addNewStep() |
||||
.withName("osh-client") |
||||
.withImage("alpine:3.12") |
||||
.withCommand("osh-cli") |
||||
.withArgs(tektonArgs) |
||||
.endStep() |
||||
.endSpec() |
||||
.build()).createOrReplace(); |
||||
|
||||
// Create TaskRun
|
||||
tkn.v1beta1().taskRuns().inNamespace(NAMESPACE).resource(new TaskRunBuilder() |
||||
.withNewMetadata().withName("tekton-osh-client-task-run").endMetadata() |
||||
.withNewSpec() |
||||
.withNewTaskRef() |
||||
.withName("tekton-osh-client") |
||||
.endTaskRef() |
||||
.endSpec() |
||||
.build()).createOrReplace(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,116 @@
|
||||
// package rest;
|
||||
|
||||
|
||||
// import io.fabric8.tekton.client.DefaultTektonClient;
|
||||
// import io.fabric8.tekton.client.TektonClient;
|
||||
|
||||
|
||||
// import javax.inject.Inject;
|
||||
// import javax.validation.Valid;
|
||||
// import javax.ws.rs.Consumes;
|
||||
// import javax.ws.rs.POST;
|
||||
// import javax.ws.rs.Path;
|
||||
// import java.net.URI;
|
||||
// import java.net.URISyntaxException;
|
||||
// import java.util.ArrayList;
|
||||
// import java.util.Arrays;
|
||||
// import java.util.List;
|
||||
// import java.util.UUID;
|
||||
// import org.json.JSONObject;
|
||||
// import org.json.JSONArray;
|
||||
// import dto.ScanObj;
|
||||
// import dto.BrewObj;
|
||||
// import dto.ConnectDB;
|
||||
// import dto.ScanObjPayload;
|
||||
// import dto.BrewObjPayload;
|
||||
// import dto.GitObj;
|
||||
// import dto.GitObjPayload;
|
||||
// import dto.PncObj;
|
||||
// import dto.PncObjPayload;
|
||||
|
||||
// import static constants.HttpHeaders.AUTHORIZATION_STRING;
|
||||
// import java.sql.Connection;
|
||||
// import java.sql.DriverManager;
|
||||
// import java.sql.SQLException;
|
||||
|
||||
// import java.sql.Connection;
|
||||
// import java.sql.DriverManager;
|
||||
// import java.sql.ResultSet;
|
||||
// import java.sql.Statement;
|
||||
|
||||
// import java.util.Collections;
|
||||
// import java.util.LinkedHashMap;
|
||||
// import java.util.Set;
|
||||
// import dto.ScanObj;
|
||||
// import dto.ConnectDB;
|
||||
|
||||
// import java.sql.Connection;
|
||||
// import java.sql.DriverManager;
|
||||
// import java.sql.SQLException;
|
||||
|
||||
// import java.sql.Connection;
|
||||
// import java.sql.DriverManager;
|
||||
// import java.sql.ResultSet;
|
||||
// import java.sql.Statement;
|
||||
|
||||
// import javax.ws.rs.DELETE;
|
||||
// import javax.ws.rs.GET;
|
||||
// import javax.ws.rs.POST;
|
||||
// import javax.ws.rs.Path;
|
||||
// import javax.inject.Inject;
|
||||
// import javax.ws.rs.GET;
|
||||
// import javax.ws.rs.Path;
|
||||
// import javax.ws.rs.PathParam;
|
||||
// import java.util.Set;
|
||||
// import java.util.stream.Collectors;
|
||||
// import javax.inject.Inject;
|
||||
// import javax.ws.rs.Consumes;
|
||||
|
||||
// import java.sql.*;
|
||||
|
||||
// import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
// import com.fasterxml.jackson.databind.ObjectWriter;
|
||||
|
||||
// // import org.hibernate.EntityManager;
|
||||
// import jakarta.persistence.EntityManager;
|
||||
// import jakarta.persistence.Cacheable;
|
||||
// import jakarta.persistence.Column;
|
||||
// import jakarta.persistence.Entity;
|
||||
// import jakarta.persistence.GeneratedValue;
|
||||
// import jakarta.persistence.Id;
|
||||
// import jakarta.persistence.NamedQuery;
|
||||
// import jakarta.persistence.QueryHint;
|
||||
// import jakarta.persistence.SequenceGenerator;
|
||||
// import jakarta.persistence.Table;
|
||||
|
||||
|
||||
// import io.fabric8.tekton.client.DefaultTektonClient;
|
||||
// import io.fabric8.tekton.client.TektonClient;
|
||||
// import io.fabric8.tekton.pipeline.v1beta1.TaskBuilder;
|
||||
// import io.fabric8.tekton.pipeline.v1beta1.Task;
|
||||
|
||||
// public class callTekton {
|
||||
|
||||
// private static final String NAMESPACE = "default";
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// try (TektonClient tkn = new DefaultTektonClient()) {
|
||||
// // Load Task object from YAML
|
||||
// Task task = tkn.v1beta1()
|
||||
// .tasks()
|
||||
// .load(callTekton.class.getResourceAsStream("../resources/baseScan.yml")).get();
|
||||
|
||||
// // Create Task object into Kubernetes
|
||||
// tkn.v1beta1().tasks().inNamespace(NAMESPACE).createOrReplace(task);
|
||||
|
||||
// // Get Task object from APIServer
|
||||
// String taskName = task.getMetadata().getName();
|
||||
// task = tkn.v1beta1().tasks().inNamespace(NAMESPACE)
|
||||
// .withName(taskName)
|
||||
// .get();
|
||||
|
||||
// // Delete Task object
|
||||
// tkn.v1beta1().tasks().inNamespace(NAMESPACE).withName(taskName).delete();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@ -0,0 +1,16 @@
|
||||
apiVersion: tekton.dev/v1beta1 |
||||
kind: Task |
||||
metadata: |
||||
name: basescan |
||||
spec: |
||||
params: |
||||
- name: buildId |
||||
type: string |
||||
- name: config |
||||
type: string |
||||
steps: |
||||
- name: baseScan |
||||
image: openshift |
||||
script: | |
||||
#!/bin/bash |
||||
osh-cli mock-build --config=params.config --brew-build params.buildId |
||||
Loading…
Reference in new issue