Use focused native configuration inspection
This commit is contained in:
@@ -8,24 +8,30 @@ import (
|
||||
"go.maximumdirect.net/configkit"
|
||||
)
|
||||
|
||||
// Inspection is the read-only subset of the retained ConfigKit result used by
|
||||
// Inspection is the read-only subset of the native ConfigKit view used by
|
||||
// the facade. It does not expose typed configuration or resource contexts.
|
||||
type Inspection interface {
|
||||
Metadata() configkit.Metadata
|
||||
Sources() []configkit.SourceInfo
|
||||
Diagnostics() []configkit.Diagnostic
|
||||
HistoricalPaths() []configkit.Path
|
||||
Explain(configkit.Path) (configkit.Explanation, bool)
|
||||
WriteEffective(io.Writer) error
|
||||
WriteExplanation(io.Writer, configkit.Path) error
|
||||
capturedResult() *configkit.Result[document]
|
||||
nativeView() configkit.Inspection
|
||||
}
|
||||
|
||||
type inspectionResult struct {
|
||||
*configkit.Result[document]
|
||||
configkit.Inspection
|
||||
diagnostics []configkit.Diagnostic
|
||||
}
|
||||
|
||||
func (inspection inspectionResult) capturedResult() *configkit.Result[document] {
|
||||
return inspection.Result
|
||||
func (inspection inspectionResult) nativeView() configkit.Inspection {
|
||||
return inspection.Inspection
|
||||
}
|
||||
|
||||
func (inspection inspectionResult) Diagnostics() []configkit.Diagnostic {
|
||||
return ownDiagnostics(inspection.diagnostics)
|
||||
}
|
||||
|
||||
// Inspection returns only the retained result's inspection operations.
|
||||
@@ -33,19 +39,12 @@ func (state *loaded) Inspection() Inspection {
|
||||
if state == nil {
|
||||
return nil
|
||||
}
|
||||
return inspectionResult{Result: state.result}
|
||||
return inspectionResult{Inspection: state.view, diagnostics: state.diagnostics}
|
||||
}
|
||||
|
||||
// Diff compares two captured ConfigKit results without reconstructing them.
|
||||
func Diff(left, right Inspection) ([]configkit.Difference, error) {
|
||||
var leftResult, rightResult *configkit.Result[document]
|
||||
if left != nil {
|
||||
leftResult = left.capturedResult()
|
||||
}
|
||||
if right != nil {
|
||||
rightResult = right.capturedResult()
|
||||
}
|
||||
return configkit.Diff(leftResult, rightResult)
|
||||
return left.nativeView().Diff(right.nativeView())
|
||||
}
|
||||
|
||||
// Sensitive marks credential-shaped provider values beneath PromptKit settings.
|
||||
|
||||
Reference in New Issue
Block a user