Activate sibling inheritance in configuration loading
This commit is contained in:
36
records.go
36
records.go
@@ -32,7 +32,10 @@ type ChangeKind string
|
||||
const (
|
||||
// ChangeDecoding records the built-in transition to canonical typed values.
|
||||
// It is inspection metadata, not an operation accepted by Resolution.Record.
|
||||
ChangeDecoding ChangeKind = "decoding"
|
||||
ChangeDecoding ChangeKind = "decoding"
|
||||
// ChangeInheritance records structural input expansion. It is inspection
|
||||
// metadata, not an operation accepted by Resolution.Record.
|
||||
ChangeInheritance ChangeKind = "inheritance"
|
||||
ChangeDerivedDefault ChangeKind = "derived_default"
|
||||
ChangeNormalization ChangeKind = "normalization"
|
||||
)
|
||||
@@ -161,6 +164,11 @@ const (
|
||||
CodeOverrideLimitExceeded Code = "override.limit_exceeded"
|
||||
|
||||
CodeExplainLimitExceeded Code = "explain.limit_exceeded"
|
||||
|
||||
CodeInheritanceInvalid Code = "inheritance.invalid"
|
||||
CodeInheritanceMissing Code = "inheritance.missing"
|
||||
CodeInheritanceCycle Code = "inheritance.cycle"
|
||||
CodeInheritanceVersion Code = "inheritance.version"
|
||||
)
|
||||
|
||||
// Location identifies a position in a configuration source. Zero line and column
|
||||
@@ -197,13 +205,23 @@ type Diagnostic struct {
|
||||
Related []Location
|
||||
}
|
||||
|
||||
// InheritanceStep identifies a concrete payload transfer controlled by a
|
||||
// relationship directive. Locations belong to that directive, not its value.
|
||||
type InheritanceStep struct {
|
||||
From Path
|
||||
To Path
|
||||
Reference Path
|
||||
Locations []Location
|
||||
}
|
||||
|
||||
// Origin describes where an effective definition came from. Multiple locations
|
||||
// represent a composite origin; resolution origins are synthetic and identify their
|
||||
// operation instead of a file location.
|
||||
type Origin struct {
|
||||
Layer Layer
|
||||
Locations []Location
|
||||
Operation ChangeKind
|
||||
Layer Layer
|
||||
Locations []Location
|
||||
Operation ChangeKind
|
||||
Inheritance []InheritanceStep
|
||||
}
|
||||
|
||||
// FieldInfo describes an effective configuration path.
|
||||
@@ -257,6 +275,16 @@ func cloneSourceInfos(sources []SourceInfo) []SourceInfo {
|
||||
|
||||
func cloneOrigin(origin Origin) Origin {
|
||||
origin.Locations = cloneLocations(origin.Locations)
|
||||
if origin.Inheritance != nil {
|
||||
steps := make([]InheritanceStep, len(origin.Inheritance))
|
||||
for index, step := range origin.Inheritance {
|
||||
steps[index] = InheritanceStep{
|
||||
From: step.From.clone(), To: step.To.clone(), Reference: step.Reference.clone(),
|
||||
Locations: cloneLocations(step.Locations),
|
||||
}
|
||||
}
|
||||
origin.Inheritance = steps
|
||||
}
|
||||
return origin
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user