Add audited application resolution
This commit is contained in:
28
load.go
28
load.go
@@ -39,14 +39,12 @@ type Override struct {
|
||||
Flag string
|
||||
}
|
||||
|
||||
// Resolution is the application resolution callback context. Resolution callbacks
|
||||
// are rejected until the recorded-resolution lifecycle is available.
|
||||
// Resolution exposes surviving-input presence and records audited application
|
||||
// resolution changes. A resolver must not retain or concurrently use the context.
|
||||
type Resolution struct {
|
||||
state *resolutionState
|
||||
}
|
||||
|
||||
type resolutionState struct{}
|
||||
|
||||
// VersionRule declares the input path and application checker for a schema version.
|
||||
type VersionRule struct {
|
||||
Path Path
|
||||
@@ -68,6 +66,7 @@ type Result[T any] struct {
|
||||
sources []SourceInfo
|
||||
diagnostics []Diagnostic
|
||||
final *document.Node
|
||||
resolution []resolutionSnapshot
|
||||
}
|
||||
|
||||
// Metadata returns detached effective presence, origin, and history records.
|
||||
@@ -145,12 +144,26 @@ func Load[T any](source Source, supplied ...Options[T]) (*Result[T], error) {
|
||||
}
|
||||
|
||||
configuration := decoded.value.Interface().(T)
|
||||
metadata := metadataFromDecoded(decoded)
|
||||
final := decoded.final
|
||||
var resolutionSnapshots []resolutionSnapshot
|
||||
if options.Definition.Resolve != nil {
|
||||
resolved := runResolution(&configuration, options.Definition.Resolve, schema, decoded, parsed.document)
|
||||
accumulator.add(resolved.diagnostics...)
|
||||
if hasErrors(resolved.diagnostics) {
|
||||
return nil, accumulator.loadError()
|
||||
}
|
||||
final = resolved.final
|
||||
resolutionSnapshots = resolved.snapshots
|
||||
applyResolutionMetadata(&metadata, resolved)
|
||||
}
|
||||
return &Result[T]{
|
||||
Config: configuration,
|
||||
metadata: metadataFromDecoded(decoded),
|
||||
metadata: metadata,
|
||||
sources: cloneSourceInfos(accumulator.sources),
|
||||
diagnostics: canonicalDiagnostics(accumulator.diagnostics),
|
||||
final: document.Clone(decoded.final),
|
||||
final: document.Clone(final),
|
||||
resolution: cloneResolutionSnapshots(resolutionSnapshots),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -164,9 +177,6 @@ func selectOptions[T any](source Source, supplied []Options[T]) (Options[T], []D
|
||||
}
|
||||
var diagnostics []Diagnostic
|
||||
definition := options.Definition
|
||||
if definition.Resolve != nil {
|
||||
diagnostics = append(diagnostics, optionDiagnostic(CodeOptionsUnavailable, "application resolution is not available in this release boundary"))
|
||||
}
|
||||
if definition.Validate != nil {
|
||||
diagnostics = append(diagnostics, optionDiagnostic(CodeOptionsUnavailable, "application validation is not available in this release boundary"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user