Render focused inspection values safely

This commit is contained in:
2026-11-21 04:07:57 +00:00
parent 68a6da2388
commit db743a4b3d
4 changed files with 87 additions and 1 deletions

View File

@@ -1,5 +1,11 @@
package engine
import (
"io"
yamladapter "go.maximumdirect.net/configkit/internal/yaml"
)
// InspectionView borrows an inspection and selects a canonical reporting scope.
type InspectionView struct {
inspection *Inspection
@@ -19,6 +25,17 @@ func NewInspectionView(inspection *Inspection, scope Path) (InspectionView, bool
func (v InspectionView) Inspection() *Inspection { return v.inspection }
func (v InspectionView) WriteEffective(output io.Writer) error {
if v.inspection == nil || v.inspection.final == nil || output == nil {
return errEffectiveUnavailable
}
node, ok := documentAtPathWithLookup(v.inspection.final, v.scope, v.inspection.documentLookup())
if !ok {
return errEffectiveUnavailable
}
return yamladapter.Write(output, redactedDocument(node, v.inspection.secrets, v.scope))
}
func (v InspectionView) HistoricalPaths() []Path {
if v.inspection == nil {
return nil