chopping through index changes, basic design works.

seems to be holding, more tests to change.

Signed-off-by: quobix <dave@quobix.com>
This commit is contained in:
quobix
2023-10-16 14:56:58 -04:00
parent d5f72a2a2e
commit cea7bb0cc8
8 changed files with 183 additions and 128 deletions

View File

@@ -348,17 +348,28 @@ func (index *SpecIndex) performExternalLookup(uri []string) *Reference {
absoluteFileLocation, _ = filepath.Abs(filepath.Join(filepath.Dir(index.specAbsolutePath), file))
}
// extract the document from the rolodex.
rFile, rError := index.rolodex.Open(absoluteFileLocation)
if rError != nil {
logger.Error("unable to open rolodex file", "file", absoluteFileLocation, "error", rError)
return nil
}
// if the absolute file location has no file ext, then get the rolodex root.
ext := filepath.Ext(absoluteFileLocation)
parsedDocument, err := rFile.GetContentAsYAMLNode()
if err != nil {
logger.Error("unable to parse rolodex file", "file", absoluteFileLocation, "error", err)
return nil
var parsedDocument *yaml.Node
var err error
if ext != "" {
// extract the document from the rolodex.
rFile, rError := index.rolodex.Open(absoluteFileLocation)
if rError != nil {
logger.Error("unable to open rolodex file", "file", absoluteFileLocation, "error", rError)
return nil
}
parsedDocument, err = rFile.GetContentAsYAMLNode()
if err != nil {
logger.Error("unable to parse rolodex file", "file", absoluteFileLocation, "error", err)
return nil
}
} else {
parsedDocument = index.root
}
//fmt.Printf("parsedDocument: %v\n", parsedDocument)