5 changed files with 239 additions and 0 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,82 @@ |
|||||||
|
// package io.rest;
|
||||||
|
|
||||||
|
// import io.fabric8.tekton.client.DefaultTektonClient;
|
||||||
|
// import io.fabric8.tekton.client.TektonClient;
|
||||||
|
|
||||||
|
// 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.ConnectDB;
|
||||||
|
// import dto.ScanObjPayload;
|
||||||
|
|
||||||
|
// import static constants.HttpHeaders.AUTHORIZATION_STRING;
|
||||||
|
// import java.sql.Connection;
|
||||||
|
// import java.sql.DriverManager;
|
||||||
|
// import java.sql.SQLException;
|
||||||
|
|
||||||
|
|
||||||
|
// import io.fabric8.tekton.client.DefaultTektonClient;
|
||||||
|
// import io.fabric8.tekton.client.TektonClient;
|
||||||
|
// import io.fabric8.tekton.pipeline.v1beta1.ArrayOrString;
|
||||||
|
// import io.fabric8.tekton.pipeline.v1beta1.PipelineRunBuilder;
|
||||||
|
// import io.fabric8.tekton.triggers.v1alpha1.TriggerTemplateBuilder;
|
||||||
|
|
||||||
|
// import java.util.Collections;
|
||||||
|
|
||||||
|
// import java.sql.Connection;
|
||||||
|
// import java.sql.DriverManager;
|
||||||
|
// import java.sql.ResultSet;
|
||||||
|
// import java.sql.Statement;
|
||||||
|
|
||||||
|
// @Path("/tektonCall")
|
||||||
|
// public class TektonTaskCreate {
|
||||||
|
|
||||||
|
// private static final String NAMESPACE = "default";
|
||||||
|
|
||||||
|
// @RestClient
|
||||||
|
|
||||||
|
// @POST
|
||||||
|
// @Consumes({ "application/json" })
|
||||||
|
|
||||||
|
// public void invokeTektonTask(@Valid String nvr) throws URISyntaxException {
|
||||||
|
// try (TektonClient tkn = new DefaultTektonClient()) {
|
||||||
|
// // Create Task
|
||||||
|
// String argCall = String.format("mock-build --config=rhel-r-x86_64 --brew-build %s",nvr);
|
||||||
|
// tkn.v1beta1().tasks().inNamespace(NAMESPACE).createOrReplace()
|
||||||
|
// .withNewMetadata().withName("tekton-osh-cli").endMetadata()
|
||||||
|
// .withNewSpec()
|
||||||
|
// .addNewStep()
|
||||||
|
// .withName("osh-config")
|
||||||
|
// .withImage("alpine:3.12")
|
||||||
|
// .withCommand("osh-cli")
|
||||||
|
// .withArgs(argCall)
|
||||||
|
// .endStep()
|
||||||
|
// .endSpec()
|
||||||
|
// .done();
|
||||||
|
|
||||||
|
// // Create TaskRun
|
||||||
|
// tkn.v1beta1().taskRuns().inNamespace(NAMESPACE).createOrReplace()
|
||||||
|
// .withNewMetadata().withName("tekton-osh-cli-task-run").endMetadata()
|
||||||
|
// .withNewSpec()
|
||||||
|
// .withNewTaskRef()
|
||||||
|
// .withName("tekton-osh-cli")
|
||||||
|
// .endTaskRef()
|
||||||
|
// .endSpec()
|
||||||
|
// .done();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
@ -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: ubuntu |
||||||
|
script: | |
||||||
|
#!/bin/bash |
||||||
|
osh-cli mock-build --config=params.config --brew-build params.buildId |
||||||
@ -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("/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(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue