Render final configuration through native snapshots
This commit is contained in:
@@ -4,11 +4,13 @@ import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
|
||||
configkit "go.maximumdirect.net/configkit"
|
||||
)
|
||||
|
||||
const (
|
||||
pipelineDefaultOwnershipSource = "default"
|
||||
effectivePipelineDigestVersion = "narratio-effective-pipeline-v3\n"
|
||||
effectivePipelineDigestVersion = "narratio-effective-pipeline-v4\n"
|
||||
)
|
||||
|
||||
// PipelineOverlayProvenance identifies the overlay selected while resolving a
|
||||
@@ -51,12 +53,22 @@ func recomputePipelineEffectiveDigest(cfg *PipelineConfig) error {
|
||||
if cfg == nil || cfg.resolution == nil {
|
||||
return fmt.Errorf("pipeline resolution metadata is required")
|
||||
}
|
||||
canonical, err := projectionJSON(projectEffectivePipeline(cfg))
|
||||
snapshot, err := newPipelineInspection(cfg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
canonical, err := projectionJSON(snapshot.Config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
digestInput := append([]byte(effectivePipelineDigestVersion), canonical...)
|
||||
digest := sha256.Sum256(digestInput)
|
||||
cfg.resolution.effectiveDigest = hex.EncodeToString(digest[:])
|
||||
cfg.resolution.inspection = snapshot
|
||||
return nil
|
||||
}
|
||||
|
||||
func newPipelineInspection(cfg *PipelineConfig) (*configkit.Result[effectivePipelineProjection], error) {
|
||||
projection := projectEffectivePipeline(cfg)
|
||||
return configkit.Load(configkit.NoSource(), configkit.Options[effectivePipelineProjection]{Definition: configkit.Definition[effectivePipelineProjection]{Defaults: func() effectivePipelineProjection { return projection }}})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user