Publish domain artifacts without reporting sidecars
This commit is contained in:
@@ -2,10 +2,8 @@ package pipeline
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/core/artifacts"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
)
|
||||
|
||||
@@ -89,12 +87,11 @@ func buildStepReferenceReuseEligibility(step PreparedPipelineStep, outputs map[g
|
||||
// buildStepReferenceSets resolves every generated binding for a step before
|
||||
// any lane in that step is allowed to start. Each returned set is a fresh
|
||||
// operation-time view; prepared reference sets are never modified.
|
||||
func buildStepReferenceSets(input RunInput, step PreparedPipelineStep, outputs []contracts.SerializedOutput) (map[referenceTargetKey]contracts.ReferenceSet, []artifacts.ReferenceProvenance, error) {
|
||||
func buildStepReferenceSets(input RunInput, step PreparedPipelineStep, outputs []contracts.SerializedOutput) (map[referenceTargetKey]contracts.ReferenceSet, error) {
|
||||
if len(step.lanes) == 0 {
|
||||
return nil, nil, nil
|
||||
return nil, nil
|
||||
}
|
||||
sets := make(map[referenceTargetKey]contracts.ReferenceSet)
|
||||
var provenance []artifacts.ReferenceProvenance
|
||||
outputsByProducer := indexGeneratedOutputs(outputs)
|
||||
canonical := make(map[generatedOutputKey]contracts.ReferenceItem)
|
||||
for _, prepared := range step.lanes {
|
||||
@@ -109,24 +106,24 @@ func buildStepReferenceSets(input RunInput, step PreparedPipelineStep, outputs [
|
||||
generated = true
|
||||
item, err := generatedReferenceItem(input, binding, outputsByProducer, canonical)
|
||||
if err != nil {
|
||||
return nil, nil, contextualHandoffError(input, target, binding, err)
|
||||
return nil, contextualHandoffError(input, target, binding, err)
|
||||
}
|
||||
slotName := strings.TrimSpace(binding.SlotName)
|
||||
slot, ok := resolved.Slots[slotName]
|
||||
if !ok {
|
||||
return nil, nil, contextualHandoffError(input, target, binding, fmt.Errorf("reference slot %q has no resolved declaration", slotName))
|
||||
return nil, contextualHandoffError(input, target, binding, fmt.Errorf("reference slot %q has no resolved declaration", slotName))
|
||||
}
|
||||
if len(slot.Items) > 0 {
|
||||
return nil, nil, contextualHandoffError(input, target, binding, fmt.Errorf("reference slot %q already contains materialized items", slotName))
|
||||
return nil, contextualHandoffError(input, target, binding, fmt.Errorf("reference slot %q already contains materialized items", slotName))
|
||||
}
|
||||
if len(slot.Slot.AcceptedArtifactKinds) == 0 || !containsArtifactKind(slot.Slot.AcceptedArtifactKinds, item.ArtifactKind) {
|
||||
return nil, nil, contextualHandoffError(input, target, binding, fmt.Errorf("reference slot %q does not accept artifact kind %q", slotName, item.ArtifactKind))
|
||||
return nil, contextualHandoffError(input, target, binding, fmt.Errorf("reference slot %q does not accept artifact kind %q", slotName, item.ArtifactKind))
|
||||
}
|
||||
if !referenceMediaTypeAccepted(item.MediaType, slot.Slot.AcceptedMediaTypes) {
|
||||
return nil, nil, contextualHandoffError(input, target, binding, fmt.Errorf("reference slot %q does not accept media type %q", slotName, item.MediaType))
|
||||
return nil, contextualHandoffError(input, target, binding, fmt.Errorf("reference slot %q does not accept media type %q", slotName, item.MediaType))
|
||||
}
|
||||
if slot.Slot.MaxBytes > 0 && item.SizeBytes > slot.Slot.MaxBytes {
|
||||
return nil, nil, contextualHandoffError(input, target, binding, fmt.Errorf("reference slot %q is %d bytes, limit %d", slotName, item.SizeBytes, slot.Slot.MaxBytes))
|
||||
return nil, contextualHandoffError(input, target, binding, fmt.Errorf("reference slot %q is %d bytes, limit %d", slotName, item.SizeBytes, slot.Slot.MaxBytes))
|
||||
}
|
||||
slot.Items = []contracts.ReferenceItem{contracts.CloneReferenceItem(item)}
|
||||
resolved.Slots[slotName] = slot
|
||||
@@ -136,12 +133,9 @@ func buildStepReferenceSets(input RunInput, step PreparedPipelineStep, outputs [
|
||||
}
|
||||
key := keyForReferenceTarget(target)
|
||||
sets[key] = resolved
|
||||
for _, item := range generatedItems(resolved) {
|
||||
provenance = append(provenance, referenceProvenanceForItem(target, item))
|
||||
}
|
||||
}
|
||||
}
|
||||
return sets, provenance, nil
|
||||
return sets, nil
|
||||
}
|
||||
|
||||
func containsArtifactKind(kinds []contracts.ArtifactKind, want contracts.ArtifactKind) bool {
|
||||
@@ -257,44 +251,3 @@ func findResolvedLane(pipeline ResolvedPipeline, stepID, laneID string) (Resolve
|
||||
}
|
||||
return ResolvedArtifactLane{}, false
|
||||
}
|
||||
|
||||
func generatedItems(set contracts.ReferenceSet) []contracts.ReferenceItem {
|
||||
var items []contracts.ReferenceItem
|
||||
keys := make([]string, 0, len(set.Slots))
|
||||
for key := range set.Slots {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
for _, key := range keys {
|
||||
for _, item := range set.Slots[key].Items {
|
||||
if item.Origin.Type == "generated" {
|
||||
items = append(items, item)
|
||||
}
|
||||
}
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
func referenceProvenanceForItem(target ResolvedReferenceTarget, item contracts.ReferenceItem) artifacts.ReferenceProvenance {
|
||||
return artifacts.ReferenceProvenance{
|
||||
Stage: string(target.Stage),
|
||||
StepID: target.StepID,
|
||||
LaneID: target.LaneID,
|
||||
SlotName: item.SlotName,
|
||||
OriginType: item.Origin.Type,
|
||||
OriginURI: item.Origin.URI,
|
||||
Digest: item.Digest,
|
||||
MediaType: item.MediaType,
|
||||
SizeBytes: item.SizeBytes,
|
||||
BindingSource: item.BindingSource,
|
||||
ArtifactKind: string(item.ArtifactKind),
|
||||
SchemaID: item.ArtifactSchema.ID,
|
||||
SchemaName: item.ArtifactSchema.Name,
|
||||
SchemaVersion: item.ArtifactSchema.Version,
|
||||
SchemaDigest: contracts.DigestArtifactSchema(item.ArtifactSchema),
|
||||
ProducerPipeline: item.Producer.PipelineID,
|
||||
ProducerStep: item.Producer.StepID,
|
||||
ProducerLane: item.Producer.LaneID,
|
||||
ProducerModule: item.Producer.ModuleKey,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user