Skip to content

Commit

Permalink
Console files
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Jan 22, 2024
1 parent eba923a commit 063f300
Show file tree
Hide file tree
Showing 11 changed files with 183 additions and 107 deletions.
3 changes: 3 additions & 0 deletions deploy/crds/base/jvmbuildservice.io_dependencybuilds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ spec:
required:
- imageDigest
type: object
startTime:
format: int64
type: integer
succeeded:
type: boolean
required:
Expand Down
48 changes: 48 additions & 0 deletions deploy/overlays/dev-template/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ rules:
- jvmbuildservice.io
resources:
- artifactbuilds
<<<<<<< HEAD
=======
- artifactbuilds/status
- jvmimagescans
- jvmimagescans/status
- dependencybuilds
- dependencybuilds/status
>>>>>>> 17f80a76 (Console files)
verbs:
- get
- list
Expand All @@ -30,14 +38,54 @@ rules:
- apiGroups:
- tekton.dev
resources:
<<<<<<< HEAD
- taskruns/status
- pipelineruns/status
- taskruns/status
=======
- taskruns
- taskruns/status
- pipelineruns
>>>>>>> 17f80a76 (Console files)
- pipelineruns/status
verbs:
- get
- list
- watch
<<<<<<< HEAD
=======

- apiGroups:
- ""
resources:
- pods
- pods/log
verbs:
- get
- list
- watch
- apiGroups:
- "apps"
resources:
- deployments
verbs:
- get
- list
- watch
- apiGroups:
- ""
# note - tekton gives its controller read access to secrets, so any pods there can access secrets in the pods namespace
resources:
- secrets
resourceNames:
- jbs-user-secret
verbs:
- get
- create
- watch
- update
- patch
>>>>>>> 17f80a76 (Console files)
---
apiVersion: v1
kind: ServiceAccount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ public void doImport(DependencyBuild dependencyBuild) {
scm.getPath(), dependencyBuild.getMetadata().getName());

StoredDependencyBuild storedBuild = StoredDependencyBuild
.find("buildIdentifier = :buildIdentifier and uid = :uid",
Parameters.with("buildIdentifier", identifier).and("uid", dependencyBuild.getMetadata().getUid()))
.find("buildIdentifier = :buildIdentifier",
Parameters.with("buildIdentifier", identifier))
.firstResult();
if (storedBuild == null) {
storedBuild = new StoredDependencyBuild();
storedBuild.buildIdentifier = identifier;
storedBuild.uid = dependencyBuild.getMetadata().getUid();
}
storedBuild.uid = dependencyBuild.getMetadata().getUid();
if (s3Bucket != null) {
storedBuild.buildYamlUrl = "s3://" + s3Bucket + "/builds/" + dependencyBuild.getMetadata().getName() + "/"
+ dependencyBuild.getMetadata().getUid() + ".yaml";
Expand Down Expand Up @@ -114,9 +114,19 @@ public void doImport(DependencyBuild dependencyBuild) {
}
if (dependencyBuild.getStatus().getBuildAttempts() != null) {
for (var i : dependencyBuild.getStatus().getBuildAttempts()) {
BuildAttempt attempt = new BuildAttempt();
boolean found = false;
BuildAttempt attempt = null;
for (var ba : storedBuild.buildAttempts) {
if (ba.startTime != null && ba.startTime.getTime() == i.getBuild().getStartTime()) {
//existing one, just update it
attempt = ba;
}
}
if (attempt == null) {
attempt = new BuildAttempt();
storedBuild.buildAttempts.add(attempt);
}
attempt.dependencyBuild = storedBuild;
storedBuild.buildAttempts.add(attempt);
attempt.jdk = i.getBuildRecipe().getJavaVersion();
attempt.mavenVersion = i.getBuildRecipe().getToolVersions().get("maven");
attempt.gradleVersion = i.getBuildRecipe().getToolVersions().get("gradle");
Expand All @@ -136,10 +146,11 @@ public void doImport(DependencyBuild dependencyBuild) {
: i.getBuildRecipe().getAllowedDifferences().stream()
.collect(Collectors.joining("\n"));
attempt.successful = Boolean.TRUE.equals(i.getBuild().getSucceeded());
var finalAttempt = attempt;
if (i.getBuildRecipe().getAdditionalDownloads() != null) {
attempt.additionalDownloads = i.getBuildRecipe().getAdditionalDownloads().stream().map(s -> {
AdditionalDownload download = new AdditionalDownload();
download.buildAttempt = attempt;
download.buildAttempt = finalAttempt;
download.binaryPath = s.getBinaryPath();
download.fileName = s.getFileName();
download.packageName = s.getPackageName();
Expand All @@ -149,7 +160,7 @@ public void doImport(DependencyBuild dependencyBuild) {
return download;
}).collect(Collectors.toList());
}
mavenRepo.ifPresent(s -> attempt.mavenRepository = s.replace("/repository/maven-releases",
mavenRepo.ifPresent(s -> finalAttempt.mavenRepository = s.replace("/repository/maven-releases",
"/service/rest/repository/browse/maven-releases"));

if (s3Bucket != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.redhat.hacbs.management.model;

import java.util.Date;
import java.util.List;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -74,6 +77,10 @@ public class BuildAttempt extends PanacheEntity {
@Column(length = -1)
public String gitArchiveUrl;

@Column
@Temporal(TemporalType.TIMESTAMP)
public Date startTime;

//this is pretty yuck, but we don't want a whole new table to store a List<String>
public void commandLine(List<String> commandLine) {
var mapper = Arc.container().instance(ObjectMapper.class);
Expand All @@ -92,4 +99,5 @@ public List<String> commandLine() {
throw new RuntimeException(e);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import io.quarkus.hibernate.orm.panache.PanacheEntity;

@Entity
@Table(uniqueConstraints = @UniqueConstraint(columnNames = { "buildidentifier_id", "uid" }))
@Table(uniqueConstraints = @UniqueConstraint(columnNames = { "buildidentifier_id" }))
public class StoredDependencyBuild extends PanacheEntity {

@ManyToOne(optional = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void setup() {
@Override
public void run() {

client.resources(Pod.class).inAnyNamespace().inform(new ResourceEventHandler<Pod>() {
client.resources(Pod.class).inform(new ResourceEventHandler<Pod>() {
@Override
public void onAdd(Pod resource) {
if (resource.getMetadata().getName().contains("jvm-build-workspace-artifact-cache")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void setup() {
Log.warnf("image scan importer disabled");
return;
}
client.resources(JvmImageScan.class).inAnyNamespace().inform(new ResourceEventHandler<JvmImageScan>() {
client.resources(JvmImageScan.class).inform(new ResourceEventHandler<JvmImageScan>() {
@Override
public void onAdd(JvmImageScan obj) {
ContainerImage image = ensureImageExists(obj);
Expand Down
Loading

0 comments on commit 063f300

Please sign in to comment.