diff --git a/java-components/management-console/src/main/java/com/redhat/hacbs/management/dto/BuildDTO.java b/java-components/management-console/src/main/java/com/redhat/hacbs/management/dto/BuildDTO.java index 5fb08e487..4d2c33458 100644 --- a/java-components/management-console/src/main/java/com/redhat/hacbs/management/dto/BuildDTO.java +++ b/java-components/management-console/src/main/java/com/redhat/hacbs/management/dto/BuildDTO.java @@ -2,11 +2,15 @@ import java.util.List; +import jakarta.persistence.EntityManager; + import org.eclipse.microprofile.openapi.annotations.media.Schema; import com.redhat.hacbs.management.model.MavenArtifact; import com.redhat.hacbs.management.model.StoredDependencyBuild; +import io.quarkus.arc.Arc; + public record BuildDTO( @Schema(required = true) long id, @Schema(required = true) String name, @@ -18,8 +22,19 @@ public record BuildDTO( boolean contaminated, List artifacts, BuildAttemptDTO successfulBuild, - List buildAttempts) { + List buildAttempts, + + boolean inQueue) { public static BuildDTO of(StoredDependencyBuild build) { + EntityManager entityManager = Arc.container().instance(EntityManager.class).get(); + var inQueue = false; + Long n = (Long) entityManager.createQuery( + "select count(*) from StoredArtifactBuild a inner join BuildQueue b on b.mavenArtifact=a.mavenArtifact where a.buildIdentifier=:b") + .setParameter("b", build.buildIdentifier).getSingleResult(); + if (n > 0) { + inQueue = true; + } + BuildAttemptDTO success = build.buildAttempts.stream().filter(s -> s.successful).findFirst().map(BuildAttemptDTO::of) .orElse(null); List others = build.buildAttempts.stream().filter(s -> success == null || s.id != success.id()) @@ -35,7 +50,8 @@ public static BuildDTO of(StoredDependencyBuild build) { build.contaminated, build.producedArtifacts.stream().map(MavenArtifact::gav).toList(), success, - others); + others, + inQueue); } } diff --git a/java-components/management-console/src/main/java/com/redhat/hacbs/management/dto/DeploymentDTO.java b/java-components/management-console/src/main/java/com/redhat/hacbs/management/dto/DeploymentDTO.java index c40adae3e..cee937786 100644 --- a/java-components/management-console/src/main/java/com/redhat/hacbs/management/dto/DeploymentDTO.java +++ b/java-components/management-console/src/main/java/com/redhat/hacbs/management/dto/DeploymentDTO.java @@ -31,12 +31,26 @@ public long getUntrustedDependencies() { return dependencies.stream() .filter(s -> !(Objects.equals(s.source, "rebuild") || Objects.equals(s.source, "redhat"))).count(); } + + @Schema(required = true) + public long getTrustedDependencies() { + return dependencies.stream() + .filter(s -> Objects.equals(s.source, "rebuild") || Objects.equals(s.source, "redhat")).count(); + } + + @Schema(required = true) + public long getAvailableBuilds() { + return dependencies.stream() + .filter(s -> !(Objects.equals(s.source, "rebuild") || Objects.equals(s.source, "redhat"))) + .filter(s -> s.buildSuccess).count(); + } } public record Dependency( @Schema(required = true) String gav, - @Schema(required = true) String source, String buildId, - Map attributes) implements Comparable { + @Schema(required = true) String source, Long build, @Schema(required = true) boolean inQueue, + @Schema(required = true) boolean buildSuccess, + @Schema(required = true) Map attributes) implements Comparable { @Override public int compareTo(Dependency o) { diff --git a/java-components/management-console/src/main/java/com/redhat/hacbs/management/importer/DependencyBuildImporter.java b/java-components/management-console/src/main/java/com/redhat/hacbs/management/importer/DependencyBuildImporter.java index 6d1285832..08fc97b69 100644 --- a/java-components/management-console/src/main/java/com/redhat/hacbs/management/importer/DependencyBuildImporter.java +++ b/java-components/management-console/src/main/java/com/redhat/hacbs/management/importer/DependencyBuildImporter.java @@ -84,6 +84,12 @@ public void doImport(DependencyBuild dependencyBuild) { } storedBuild.buildAttempts = new ArrayList<>(); + if (s3Bucket != null) { + //todo we just assume the logs are present + storedBuild.buildDiscoveryUrl = "s3://" + s3Bucket + "/build-logs/" + dependencyBuild.getMetadata().getName() + "/" + + dependencyBuild.getMetadata().getUid() + + "/build-discovery.log"; + } if (dependencyBuild.getStatus().getBuildAttempts() != null) { for (var i : dependencyBuild.getStatus().getBuildAttempts()) { BuildAttempt attempt = new BuildAttempt(); @@ -94,6 +100,7 @@ public void doImport(DependencyBuild dependencyBuild) { attempt.gradleVersion = i.getBuildRecipe().getToolVersions().get("gradle"); attempt.sbtVersion = i.getBuildRecipe().getToolVersions().get("sbt"); attempt.antVersion = i.getBuildRecipe().getToolVersions().get("ant"); + attempt.buildId = i.getBuildId(); attempt.tool = i.getBuildRecipe().getTool(); attempt.builderImage = i.getBuildRecipe().getImage(); attempt.commandLine(i.getBuildRecipe().getCommandLine()); diff --git a/java-components/management-console/src/main/java/com/redhat/hacbs/management/model/ArtifactIdentifier.java b/java-components/management-console/src/main/java/com/redhat/hacbs/management/model/ArtifactIdentifier.java index de3b2e2bd..d84d59e9a 100644 --- a/java-components/management-console/src/main/java/com/redhat/hacbs/management/model/ArtifactIdentifier.java +++ b/java-components/management-console/src/main/java/com/redhat/hacbs/management/model/ArtifactIdentifier.java @@ -21,8 +21,7 @@ public static ArtifactIdentifier findORCreate(String group, String artifact) { ret = new ArtifactIdentifier(); ret.artifact = artifact; ret.group = group; - ret.persist(); - + ret.persistAndFlush(); } return ret; } diff --git a/java-components/management-console/src/main/java/com/redhat/hacbs/management/model/BuildAttempt.java b/java-components/management-console/src/main/java/com/redhat/hacbs/management/model/BuildAttempt.java index abb929d1d..fc2b47688 100644 --- a/java-components/management-console/src/main/java/com/redhat/hacbs/management/model/BuildAttempt.java +++ b/java-components/management-console/src/main/java/com/redhat/hacbs/management/model/BuildAttempt.java @@ -23,6 +23,8 @@ public class BuildAttempt extends PanacheEntity { public String sbtVersion; public String antVersion; public String tool; + + public String buildId; @Column(length = -1) public String builderImage; @Column(length = -1) diff --git a/java-components/management-console/src/main/java/com/redhat/hacbs/management/model/ContainerImage.java b/java-components/management-console/src/main/java/com/redhat/hacbs/management/model/ContainerImage.java index 6f8c8b5cf..fe492bc77 100644 --- a/java-components/management-console/src/main/java/com/redhat/hacbs/management/model/ContainerImage.java +++ b/java-components/management-console/src/main/java/com/redhat/hacbs/management/model/ContainerImage.java @@ -66,7 +66,7 @@ public static ContainerImage getOrCreate(String image) { containerImage.tag = tag; containerImage.image = imagePart; containerImage.digest = digest; - containerImage.persist(); + containerImage.persistAndFlush(); } return containerImage; } diff --git a/java-components/management-console/src/main/java/com/redhat/hacbs/management/model/StoredDependencyBuild.java b/java-components/management-console/src/main/java/com/redhat/hacbs/management/model/StoredDependencyBuild.java index 7d803bdc6..0366546af 100644 --- a/java-components/management-console/src/main/java/com/redhat/hacbs/management/model/StoredDependencyBuild.java +++ b/java-components/management-console/src/main/java/com/redhat/hacbs/management/model/StoredDependencyBuild.java @@ -39,6 +39,7 @@ public class StoredDependencyBuild extends PanacheEntity { public boolean contaminated; + public String buildDiscoveryUrl; @OneToMany public List shadingDetails; diff --git a/java-components/management-console/src/main/java/com/redhat/hacbs/management/resources/BuildAttemptResource.java b/java-components/management-console/src/main/java/com/redhat/hacbs/management/resources/BuildAttemptResource.java index a4c23023a..984af5b02 100644 --- a/java-components/management-console/src/main/java/com/redhat/hacbs/management/resources/BuildAttemptResource.java +++ b/java-components/management-console/src/main/java/com/redhat/hacbs/management/resources/BuildAttemptResource.java @@ -39,7 +39,6 @@ public Response logs(@PathParam("id") int id) { .key(path); }); return Response.ok(stream, MediaType.TEXT_PLAIN_TYPE).build(); - } } diff --git a/java-components/management-console/src/main/java/com/redhat/hacbs/management/resources/BuildHistoryResource.java b/java-components/management-console/src/main/java/com/redhat/hacbs/management/resources/BuildHistoryResource.java index 7806723b3..06d87da40 100644 --- a/java-components/management-console/src/main/java/com/redhat/hacbs/management/resources/BuildHistoryResource.java +++ b/java-components/management-console/src/main/java/com/redhat/hacbs/management/resources/BuildHistoryResource.java @@ -1,5 +1,7 @@ package com.redhat.hacbs.management.resources; +import java.io.InputStream; +import java.net.URI; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -11,6 +13,8 @@ import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; import org.eclipse.microprofile.openapi.annotations.Operation; @@ -20,12 +24,17 @@ import com.redhat.hacbs.management.model.StoredArtifactBuild; import com.redhat.hacbs.management.model.StoredDependencyBuild; +import io.quarkus.logging.Log; import io.quarkus.panache.common.Page; import io.quarkus.panache.common.Sort; +import software.amazon.awssdk.services.s3.S3Client; @Path("/builds/history") public class BuildHistoryResource { + @Inject + S3Client s3Client; + @Inject EntityManager entityManager; @@ -66,4 +75,22 @@ public BuildDTO get(@PathParam("id") long id) { return BuildDTO.of(build); } + @GET + @Path("/discover-logs/{id}") + public Response logs(@PathParam("id") int id) { + StoredDependencyBuild attempt = StoredDependencyBuild.findById(id); + if (attempt == null) { + throw new NotFoundException(); + } + URI uri = URI.create(attempt.buildDiscoveryUrl); + + InputStream stream = s3Client.getObject(b -> { + String path = uri.getPath().substring(1); + String bucket = uri.getHost(); + Log.infof("requesting logs %s from bucket %s", path, bucket); + b.bucket(bucket) + .key(path); + }); + return Response.ok(stream, MediaType.TEXT_PLAIN_TYPE).build(); + } } diff --git a/java-components/management-console/src/main/java/com/redhat/hacbs/management/resources/DeploymentResource.java b/java-components/management-console/src/main/java/com/redhat/hacbs/management/resources/DeploymentResource.java index 6f555c919..10fa7c5a9 100644 --- a/java-components/management-console/src/main/java/com/redhat/hacbs/management/resources/DeploymentResource.java +++ b/java-components/management-console/src/main/java/com/redhat/hacbs/management/resources/DeploymentResource.java @@ -7,11 +7,15 @@ import java.util.Map; import jakarta.inject.Inject; +import jakarta.persistence.EntityManager; +import jakarta.persistence.NoResultException; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import com.redhat.hacbs.management.dto.DeploymentDTO; +import com.redhat.hacbs.management.model.BuildAttempt; import com.redhat.hacbs.management.model.ContainerImage; +import com.redhat.hacbs.management.model.StoredDependencyBuild; import com.redhat.hacbs.management.watcher.DeploymentWatcher; @Path("/deployment") @@ -20,6 +24,9 @@ public class DeploymentResource { @Inject DeploymentWatcher deploymentWatcher; + @Inject + EntityManager entityManager; + @GET public List getDeployments() { List ret = new ArrayList<>(); @@ -34,6 +41,8 @@ public List getDeployments() { } else { List depList = new ArrayList<>(); info.analysisComplete = existing.analysisComplete; + + //TODO: this is slow as hell for (var dep : existing.imageDependencies) { Map attributes = new HashMap<>(); if (dep.attributes != null) { @@ -42,8 +51,36 @@ public List getDeployments() { attributes.put(parts[0], parts[1]); } } + Long buildId = null; + boolean buildSuccess = false; + if (dep.buildId == null) { + try { + StoredDependencyBuild db = (StoredDependencyBuild) entityManager.createQuery( + "select b from StoredArtifactBuild s inner join StoredDependencyBuild b on b.buildIdentifier=s.buildIdentifier where s.mavenArtifact = :artifact order by b.creationTime desc") + .setParameter("artifact", dep.mavenArtifact) + .setMaxResults(1) + .getSingleResult(); + buildId = db.id; + buildSuccess = db.succeeded; + } catch (NoResultException ignore) { + } + } else { + BuildAttempt db = BuildAttempt.find("buildId", dep.buildId).singleResult(); + if (db != null) { + buildId = db.dependencyBuild.id; + buildSuccess = db.dependencyBuild.succeeded; + } + } + var inQueue = false; + Long n = (Long) entityManager.createQuery( + "select count(*) from BuildQueue b where b.mavenArtifact=:artifact") + .setParameter("artifact", dep.mavenArtifact) + .getSingleResult(); + if (n > 0) { + inQueue = true; + } DeploymentDTO.Dependency d = new DeploymentDTO.Dependency(dep.mavenArtifact.gav(), dep.source, - dep.buildId, attributes); + buildId, inQueue, buildSuccess, attributes); depList.add(d); } Collections.sort(depList); diff --git a/java-components/management-console/src/main/java/com/redhat/hacbs/management/watcher/JvmImageScanWatcher.java b/java-components/management-console/src/main/java/com/redhat/hacbs/management/watcher/JvmImageScanWatcher.java index a9ab041a7..2d087caba 100644 --- a/java-components/management-console/src/main/java/com/redhat/hacbs/management/watcher/JvmImageScanWatcher.java +++ b/java-components/management-console/src/main/java/com/redhat/hacbs/management/watcher/JvmImageScanWatcher.java @@ -10,6 +10,8 @@ import jakarta.inject.Inject; import jakarta.transaction.Transactional; +import org.hibernate.exception.ConstraintViolationException; + import com.redhat.hacbs.management.model.BuildQueue; import com.redhat.hacbs.management.model.ContainerImage; import com.redhat.hacbs.management.model.ImageDependency; @@ -43,7 +45,20 @@ public void setup() { client.resources(JvmImageScan.class).inAnyNamespace().inform(new ResourceEventHandler() { @Override public void onAdd(JvmImageScan obj) { - ExecutorRecorder.getCurrent().execute(() -> handleImage(obj)); + ContainerImage image = ensureImageExists(obj); + if (image != null) { + ExecutorRecorder.getCurrent().execute(() -> { + for (var i = 0; i < 3; ++i) { + try { + //TODO: this can be a bit racey, multiple things happening at once can add the same artifact to the DB + handleImage(obj, image.id); + return; + } catch (ConstraintViolationException e) { + Log.errorf(e, "Failed to import"); + } + } + }); + } } @Override @@ -60,35 +75,41 @@ public void onDelete(JvmImageScan obj, boolean deletedFinalStateUnknown) { } @Transactional - void handleImage(JvmImageScan resource) { + ContainerImage ensureImageExists(JvmImageScan resource) { var image = resource.getSpec().getImage(); if (!image.contains("@")) { Log.errorf("image %s has no digest, not saving scan result", image); client.resource(resource).delete(); - return; + return null; } Log.infof("Processing image scan %s", resource.getMetadata().getName()); if (resource.getStatus() == null) { - return; + return null; } if (Objects.equals(resource.getStatus().getState(), "JvmImageScanFailed")) { - ContainerImage containerImage = ContainerImage.getOrCreate(image); containerImage.analysisComplete = true; containerImage.analysisFailed = true; containerImage.persist(); - return; + return null; } if (!Objects.equals(resource.getStatus().getState(), "JvmImageScanComplete")) { - return; + return null; } - ContainerImage containerImage = ContainerImage.getOrCreate(image); + return ContainerImage.getOrCreate(image); + } + + @Transactional + void handleImage(JvmImageScan resource, long imageId) { + ContainerImage containerImage = ContainerImage.findById(imageId); if (containerImage.analysisComplete) { return; } Map existing = new HashMap<>(); - for (var i : containerImage.imageDependencies) { - existing.put(i.mavenArtifact.gav(), i); + if (containerImage.imageDependencies != null) { + for (var i : containerImage.imageDependencies) { + existing.put(i.mavenArtifact.gav(), i); + } } List results = resource.getStatus().getResults(); if (results != null) { diff --git a/java-components/management-console/src/main/webui/src/app/BuildView/BuildView.tsx b/java-components/management-console/src/main/webui/src/app/BuildView/BuildView.tsx index 76a45308a..bdbc1b34f 100644 --- a/java-components/management-console/src/main/webui/src/app/BuildView/BuildView.tsx +++ b/java-components/management-console/src/main/webui/src/app/BuildView/BuildView.tsx @@ -5,7 +5,7 @@ import { BuildAttemptDTO, BuildAttemptResourceService, BuildDTO, - BuildHistoryResourceService + BuildHistoryResourceService, BuildQueueResourceService } from "../../services/openapi"; import {RouteComponentProps} from "react-router-dom"; import { @@ -26,7 +26,7 @@ import { MenuToggle, MenuToggleElement } from "@patternfly/react-core"; -import {CheckCircleIcon, EllipsisVIcon, ErrorCircleOIcon} from "@patternfly/react-icons"; +import {CheckCircleIcon, EllipsisVIcon, ErrorCircleOIcon, IceCreamIcon} from "@patternfly/react-icons"; const columnNames = { @@ -51,6 +51,7 @@ const BuildView: React.FunctionComponent = (props) => { const [build, setBuild] = useState(initial); const [error, setError] = useState(false); const [state, setState] = useState(''); + const [isMenuOpen, setIsMenuOpen] = React.useState(false); useEffect(() => { setState('loading'); @@ -90,12 +91,56 @@ const BuildView: React.FunctionComponent = (props) => { } + const rebuild = (event: React.SyntheticEvent) => { + BuildQueueResourceService.postApiBuildsQueue(build.name) + .then(() => { + const copy = Object.assign({}, build); + copy.inQueue = true + setBuild(copy) + }) + }; + + const dropdownItems = ( + <> + {/* Prevent default onClick functionality for example purposes */} + + Rebuild + + + Build Discovery Logs + + + ); + + const headerActions = ( + <> + ) => ( + setIsMenuOpen(!isMenuOpen)} + variant="plain" + aria-label="Actions" + > + + )} + isOpen={isMenuOpen} + onOpenChange={(isOpen: boolean) => setIsMenuOpen(isOpen)} + > + {dropdownItems} + + + ); + return ( - - Build {build.scmRepo}@{build.tag}{statusIcon(build)} + + Build {build.scmRepo}@{build.tag}{statusIcon(build)} {build.inQueue && } + { @@ -104,11 +107,6 @@ const BuildRow: React.FunctionComponent = (initialBuild): event?.stopPropagation(); setActionsExpanded(!actionsExpanded); }; - const onImagesClick = (event: React.MouseEvent | undefined) => { - event?.stopPropagation(); - setImagesExpanded(!imagesExpanded); - }; - const health = function (deployment: DeploymentDTO) { if (!deployment.analysisComplete) { @@ -118,11 +116,47 @@ const BuildRow: React.FunctionComponent = (initialBuild): } let untrusted = 0 let total = 0 - deployment.images.map((i) => {total += i.totalDependencies; untrusted += i.untrustedDependencies}) + let available = 0 + deployment.images.map((i) => {total += i.totalDependencies; untrusted += i.untrustedDependencies; available += i.availableBuilds}) + let trusted = total - untrusted if (total == 0) { - return "No Java" + return } - return + return <> + {untrusted > 0 && } + {trusted > 0 && } + {available > 0 && } + + + } + + const dependencyRow = function (dep : Dependency) { + + return + + + {dep.source === 'rebuilt' && } + {dep.source === 'redhat' && } + {(dep.source !== 'redhat' && dep.source != 'rebuilt') && } + , + + {dep.build != undefined && {dep.gav}} + {dep.build == undefined &&
{dep.gav}
} +
, + + {dep.inQueue && } + {(dep.source !== 'redhat' && dep.source != 'rebuilt' && dep.buildSuccess) && } + {(dep.source !== 'redhat' && dep.source != 'rebuilt' && !dep.buildSuccess && dep.build != undefined) && } + + , + ]} + /> +
+
} return @@ -136,7 +170,7 @@ const BuildRow: React.FunctionComponent = (initialBuild): - + ,
{deployment.namespace}/{deployment.name}
@@ -146,55 +180,18 @@ const BuildRow: React.FunctionComponent = (initialBuild):
]} /> - - ) => ( - - - )} - isOpen={actionsExpanded} - onOpenChange={(isOpen: boolean) => setActionsExpanded(isOpen)} - > - - Action - {/* Prevent default onClick functionality for example - purposes */} - event.preventDefault()}> - Link - - - Disabled Action - - event.preventDefault()}> - Disabled Link - - - - - Foo {deployment.images.length} {deployment.images.map((s) => ( - <>{s.string} - {s.dependencies?.map(d => (
{d.gav}
))} + <>Image: {s.string} + + + {s.dependencies?.map(d => (dependencyRow(d)))} + ))} diff --git a/java-components/management-console/src/main/webui/src/services/openapi/models/BuildDTO.ts b/java-components/management-console/src/main/webui/src/services/openapi/models/BuildDTO.ts index fe8482440..d385ffdcd 100644 --- a/java-components/management-console/src/main/webui/src/services/openapi/models/BuildDTO.ts +++ b/java-components/management-console/src/main/webui/src/services/openapi/models/BuildDTO.ts @@ -17,5 +17,6 @@ export type BuildDTO = { artifacts?: Array; successfulBuild?: BuildAttemptDTO; buildAttempts?: Array; + inQueue?: boolean; }; diff --git a/java-components/management-console/src/main/webui/src/services/openapi/models/Dependency.ts b/java-components/management-console/src/main/webui/src/services/openapi/models/Dependency.ts index b51b52c1d..186b9928e 100644 --- a/java-components/management-console/src/main/webui/src/services/openapi/models/Dependency.ts +++ b/java-components/management-console/src/main/webui/src/services/openapi/models/Dependency.ts @@ -6,7 +6,9 @@ export type Dependency = { gav: string; source: string; - buildId?: string; - attributes?: Record; + build?: number; + inQueue: boolean; + buildSuccess: boolean; + attributes: Record; }; diff --git a/java-components/management-console/src/main/webui/src/services/openapi/models/Image.ts b/java-components/management-console/src/main/webui/src/services/openapi/models/Image.ts index c0a0fad0c..8cabd0a84 100644 --- a/java-components/management-console/src/main/webui/src/services/openapi/models/Image.ts +++ b/java-components/management-console/src/main/webui/src/services/openapi/models/Image.ts @@ -11,5 +11,7 @@ export type Image = { dependencies?: Array; totalDependencies: number; untrustedDependencies: number; + trustedDependencies: number; + availableBuilds: number; }; diff --git a/pkg/reconciler/dependencybuild/buildrecipeyaml.go b/pkg/reconciler/dependencybuild/buildrecipeyaml.go index 872cfb521..47f3eee82 100644 --- a/pkg/reconciler/dependencybuild/buildrecipeyaml.go +++ b/pkg/reconciler/dependencybuild/buildrecipeyaml.go @@ -4,8 +4,10 @@ import ( _ "embed" "encoding/base64" "fmt" + v12 "k8s.io/apimachinery/pkg/apis/meta/v1" "strconv" "strings" + "time" v1alpha12 "github.com/redhat-appstudio/jvm-build-service/pkg/apis/jvmbuildservice/v1alpha1" "github.com/redhat-appstudio/jvm-build-service/pkg/reconciler/artifactbuild" @@ -249,6 +251,7 @@ func createPipelineSpec(tool string, commitTime int64, jbsConfig *v1alpha12.JBSC }...), Steps: []pipelinev1beta1.Step{ { + Timeout: &v12.Duration{Duration: time.Hour * 3}, Name: "build", Image: "$(params." + PreBuildImageDigest + ")", ImagePullPolicy: v1.PullAlways, diff --git a/pkg/reconciler/dependencybuild/s3depencybuildsync.go b/pkg/reconciler/dependencybuild/s3depencybuildsync.go index 8b2d429c7..95bbeb249 100644 --- a/pkg/reconciler/dependencybuild/s3depencybuildsync.go +++ b/pkg/reconciler/dependencybuild/s3depencybuildsync.go @@ -109,12 +109,16 @@ func (r *ReconcileDependencyBuild) handleS3SyncPipelineRun(ctx context.Context, if sess == nil { return nil, nil } + name := pr.Name + if pr.Labels[PipelineTypeLabel] == PipelineTypeBuildInfo { + name = "build-discovery" + } uploader := s3manager.NewUploader(sess) encodedPipeline := encodeToYaml(pr) _, err = uploader.Upload(&s3manager.UploadInput{ Bucket: aws.String(bucketName), - Key: aws.String("build-pipelines/" + dep.Name + "/" + string(dep.UID) + "/" + pr.Name + ".yaml"), + Key: aws.String("build-pipelines/" + dep.Name + "/" + string(dep.UID) + "/" + name + ".yaml"), Body: strings.NewReader(encodedPipeline), ContentType: aws.String("text/yaml"), Metadata: map[string]*string{