Compose pipeline steps using native identities
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func normalizeDocumentPaths(document *Document, resolution *configkit.Resolution, state *documentLoadState) {
|
||||
normalizer := documentNormalizer{Resolution: resolution}
|
||||
if document == nil {
|
||||
return
|
||||
}
|
||||
@@ -33,24 +34,29 @@ func normalizeDocumentPaths(document *Document, resolution *configkit.Resolution
|
||||
for _, id := range sortedPipelineDocumentKeys(document.Pipelines) {
|
||||
profile := document.Pipelines[id]
|
||||
path := configkit.Keys("pipelines").Key(id)
|
||||
normalizeDocumentReferencePaths(profile.References, path.Key("references"), resolution, state)
|
||||
normalizeDocumentBindingReferencePaths(&profile.Input, path.Key("input"), resolution, state)
|
||||
normalizeDocumentReferencePaths(profile.References, path.Key("references"), normalizer, state)
|
||||
normalizeDocumentBindingReferencePaths(&profile.Input, path.Key("input"), normalizer, state)
|
||||
if profile.Chunk != nil {
|
||||
normalizeDocumentBindingReferencePaths(profile.Chunk, path.Key("chunk"), resolution, state)
|
||||
normalizeDocumentBindingReferencePaths(profile.Chunk, path.Key("chunk"), normalizer, state)
|
||||
}
|
||||
if profile.Output != nil {
|
||||
normalizeDocumentBindingReferencePaths(profile.Output, path.Key("output"), resolution, state)
|
||||
normalizeDocumentBindingReferencePaths(profile.Output, path.Key("output"), normalizer, state)
|
||||
}
|
||||
for laneID, lane := range profile.Artifacts {
|
||||
normalizeDocumentLaneReferencePaths(&lane, path.Key("artifacts").Key(laneID), resolution, state)
|
||||
normalizeDocumentLaneReferencePaths(&lane, path.Key("artifacts").Key(laneID), normalizer, state)
|
||||
profile.Artifacts[laneID] = lane
|
||||
}
|
||||
for index := range profile.Steps {
|
||||
step := &profile.Steps[index]
|
||||
stepPath := path.Key("steps").Index(index)
|
||||
normalizeDocumentReferencePaths(step.References, stepPath.Key("references"), resolution, state)
|
||||
stepNormalizer := normalizer
|
||||
if step.ID != strings.TrimSpace(step.ID) {
|
||||
resolution.RecordNormalization(path.Key("steps"), "normalized step identity")
|
||||
stepNormalizer.covered = true
|
||||
}
|
||||
normalizeDocumentReferencePaths(step.References, stepPath.Key("references"), stepNormalizer, state)
|
||||
for laneID, lane := range step.Artifacts {
|
||||
normalizeDocumentLaneReferencePaths(&lane, stepPath.Key("artifacts").Key(laneID), resolution, state)
|
||||
normalizeDocumentLaneReferencePaths(&lane, stepPath.Key("artifacts").Key(laneID), stepNormalizer, state)
|
||||
step.Artifacts[laneID] = lane
|
||||
}
|
||||
}
|
||||
@@ -75,13 +81,13 @@ func initializeDocumentMainDirectory(resolution *configkit.Resolution, state *do
|
||||
state.mainDirectory = cleanInvocationDirectory(".")
|
||||
}
|
||||
|
||||
func normalizeDocumentBindingReferencePaths(binding *BindingDocument, path configkit.Path, resolution *configkit.Resolution, state *documentLoadState) {
|
||||
func normalizeDocumentBindingReferencePaths(binding *BindingDocument, path configkit.Path, resolution documentNormalizer, state *documentLoadState) {
|
||||
if binding != nil {
|
||||
normalizeDocumentReferencePaths(binding.References, path.Key("references"), resolution, state)
|
||||
}
|
||||
}
|
||||
|
||||
func normalizeDocumentLaneReferencePaths(lane *ArtifactLaneDocument, path configkit.Path, resolution *configkit.Resolution, state *documentLoadState) {
|
||||
func normalizeDocumentLaneReferencePaths(lane *ArtifactLaneDocument, path configkit.Path, resolution documentNormalizer, state *documentLoadState) {
|
||||
if lane == nil {
|
||||
return
|
||||
}
|
||||
@@ -90,7 +96,7 @@ func normalizeDocumentLaneReferencePaths(lane *ArtifactLaneDocument, path config
|
||||
normalizeDocumentBindingReferencePaths(lane.Normalize, path.Key("normalize"), resolution, state)
|
||||
}
|
||||
|
||||
func normalizeDocumentReferencePaths(references map[string]ReferenceDocument, path configkit.Path, resolution *configkit.Resolution, state *documentLoadState) {
|
||||
func normalizeDocumentReferencePaths(references map[string]ReferenceDocument, path configkit.Path, resolution documentNormalizer, state *documentLoadState) {
|
||||
for _, name := range sortedReferenceDocumentKeys(references) {
|
||||
source := references[name]
|
||||
sourcePath := path.Key(name).Key("path")
|
||||
@@ -102,7 +108,7 @@ func normalizeDocumentReferencePaths(references map[string]ReferenceDocument, pa
|
||||
}
|
||||
}
|
||||
if source.Path != nil && *source.Path != "" && !filepath.IsAbs(*source.Path) {
|
||||
base, ok := documentPathBase(resolution, state, sourcePath)
|
||||
base, ok := documentPathBase(resolution.Resolution, state, sourcePath)
|
||||
if !ok {
|
||||
resolution.Error(sourcePath, "relative path has no unambiguous source base")
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user