Preserve derived publication and preparation evidence
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
configkit "go.maximumdirect.net/configkit"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
// EffectivePipelineRootPath reports the absolute root pipeline path retained
|
||||
@@ -218,31 +218,33 @@ func campaignDefinitionSources(campaign *CampaignConfig, path configkit.Path) []
|
||||
return nonEmptySortedStrings(sources)
|
||||
}
|
||||
|
||||
// MarshalEffectivePipeline renders the validated, normalized pipeline as one
|
||||
// deterministic YAML document. Composition declarations and runtime-only
|
||||
// resolution data are excluded. Artifact family declarations are also omitted
|
||||
// because a resolved pipeline exposes their concrete artifacts instead.
|
||||
// MarshalEffectivePipeline materializes completed configuration for persistence.
|
||||
// Credentials retain reference names; domain catalogs remain separate.
|
||||
func MarshalEffectivePipeline(cfg *PipelineConfig) ([]byte, error) {
|
||||
if cfg == nil {
|
||||
return nil, fmt.Errorf("pipeline config is required")
|
||||
}
|
||||
|
||||
var snapshot *configkit.Result[effectivePipelineProjection]
|
||||
if cfg.resolution != nil {
|
||||
snapshot = cfg.resolution.inspection
|
||||
canonical, err := projectionJSON(projectEffectivePipeline(cfg))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if snapshot == nil {
|
||||
var err error
|
||||
snapshot, err = newPipelineInspection(cfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var document yaml.Node
|
||||
if err := yaml.Unmarshal(canonical, &document); err != nil {
|
||||
return nil, fmt.Errorf("decode pipeline materialization: %w", err)
|
||||
}
|
||||
var blockStyle func(*yaml.Node)
|
||||
blockStyle = func(node *yaml.Node) {
|
||||
node.Style = 0
|
||||
for _, child := range node.Content {
|
||||
blockStyle(child)
|
||||
}
|
||||
}
|
||||
var output bytes.Buffer
|
||||
if err := snapshot.WriteEffective(&output); err != nil {
|
||||
blockStyle(&document)
|
||||
output, err := yaml.Marshal(&document)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("serialize effective pipeline: %w", err)
|
||||
}
|
||||
return output.Bytes(), nil
|
||||
return output, nil
|
||||
}
|
||||
|
||||
func effectivePipelineOwners(cfg *PipelineConfig) (map[string][]string, error) {
|
||||
|
||||
Reference in New Issue
Block a user