Expose resolution input provenance
This commit is contained in:
@@ -15,6 +15,7 @@ type resolutionState struct {
|
||||
schema *schemaDescriptor
|
||||
presence map[string]inputPresence
|
||||
document *document.Node
|
||||
input resolutionInput
|
||||
records map[string]*resolutionRecord
|
||||
diagnostics []Diagnostic
|
||||
}
|
||||
@@ -50,6 +51,27 @@ func (r *Resolution) IsExplicit(path Path) bool {
|
||||
return explicit
|
||||
}
|
||||
|
||||
// InputInfo returns detached entry-state metadata for path. The entry state is
|
||||
// the decoded configuration, including retained static defaults, immediately
|
||||
// before resolution starts. It is fixed while resolution records mutate the
|
||||
// working configuration; unknown or shape-mismatched paths return false.
|
||||
//
|
||||
// InputInfo is valid only during the resolution callback. See the configuration
|
||||
// contract for source and provenance semantics.
|
||||
func (r *Resolution) InputInfo(path Path) (FieldInfo, bool) {
|
||||
return r.activeState().input.lookup(path)
|
||||
}
|
||||
|
||||
// Source returns a detached record for a source acquired by this load. Empty or
|
||||
// unknown IDs return false and do not perform input, filesystem, or credential
|
||||
// access. A source path is present only when that acquired source has one.
|
||||
//
|
||||
// Source is valid only during the resolution callback. See the configuration
|
||||
// contract for source and provenance semantics.
|
||||
func (r *Resolution) Source(id string) (SourceInfo, bool) {
|
||||
return r.activeState().input.source(id)
|
||||
}
|
||||
|
||||
// Record declares the intent for a resolver mutation. A container path covers
|
||||
// mutations to its descendants.
|
||||
func (r *Resolution) Record(path Path, kind ChangeKind, reason string, dependencies ...Path) {
|
||||
@@ -221,9 +243,10 @@ func (state *resolutionState) addDiagnostic(code Code, path Path, message string
|
||||
state.diagnostics = append(state.diagnostics, diagnostic)
|
||||
}
|
||||
|
||||
func runResolution[T any](configuration *T, resolver func(*T, *Resolution) error, schema *schemaDescriptor, decoded decodedConfiguration, input *document.Node) resolutionResult {
|
||||
func runResolution[T any](configuration *T, resolver func(*T, *Resolution) error, schema *schemaDescriptor, decoded decodedConfiguration, input *document.Node, entry resolutionInput) resolutionResult {
|
||||
state := &resolutionState{
|
||||
active: true, schema: schema, presence: decoded.presence, document: input,
|
||||
input: entry,
|
||||
records: make(map[string]*resolutionRecord),
|
||||
}
|
||||
context := &Resolution{state: state}
|
||||
|
||||
Reference in New Issue
Block a user