Aligned CheckForCircularErrors and Resolve

the two methods were doing different things, now they are not.
This commit is contained in:
Dave Shanley
2023-02-18 18:15:35 -05:00
parent c5e9dbc360
commit fa59b5d21d
2 changed files with 2 additions and 20 deletions

View File

@@ -68,11 +68,8 @@ type SpecIndexConfig struct {
AllowRemoteLookup bool // Allow remote lookups for references. Defaults to false
AllowFileLookup bool // Allow file lookups for references. Defaults to false
// Indexes can be deeply nested, depending on how complex each spec is. If creating a sub-index
// this will help lookups remain efficient.
RootIndex *SpecIndex // if this is a sub-index, the root knows about everything below.
ParentIndex *SpecIndex // Who owns this index?
// private fields
seenRemoteSources *syncmap.Map
remoteLock *sync.Mutex
}

View File

@@ -142,22 +142,7 @@ func (resolver *Resolver) Resolve() []*ResolvingError {
// CheckForCircularReferences Check for circular references, without resolving, a non-destructive run.
func (resolver *Resolver) CheckForCircularReferences() []*ResolvingError {
mapped := resolver.specIndex.GetMappedReferencesSequenced()
mappedIndex := resolver.specIndex.GetMappedReferences()
for _, ref := range mapped {
seenReferences := make(map[string]bool)
var journey []*index.Reference
resolver.VisitReference(ref.Reference, seenReferences, journey, false)
}
schemas := resolver.specIndex.GetAllComponentSchemas()
for s, schemaRef := range schemas {
if mappedIndex[s] == nil {
seenReferences := make(map[string]bool)
var journey []*index.Reference
resolver.VisitReference(schemaRef, seenReferences, journey, false)
}
}
visitIndex(resolver, resolver.specIndex)
for _, circRef := range resolver.circularReferences {
// If the circular reference is not required, we can ignore it, as it's a terminable loop rather than an infinite one