Every `Build()` method now requires a `context.Context`. This is so the rolodex knows where to resolve from when locating relative links. Without knowing where we are, there is no way to resolve anything. This new mechanism allows the model to recurse across as many files as required to locate references, without loosing track of where we are in the process.
Signed-off-by: quobix <dave@quobix.com>
Before everything worked, but was completely accurate, now everything works and everything is absolute and can be resolved. Phew, what a mission!
Signed-off-by: quobix <dave@quobix.com>
There is a horrible amount of work to be done to clean this up, and wire in remote support. but so far, this is working as expected and is now a much cleaner design, (once everything has been cleaned up that is)
Signed-off-by: quobix <dave@quobix.com>
Like `RenderAndReload` this method will render / print out the document, however it won’t read it back in and reload the model from the ground up. This is a non-destructive method that does not reload the model from the rendered document.
If you don’t use the low model or you don’t care that the high level model and low-level models are out of sync? No problem. Otherwise keep this in mind that the low level model will only represent the original un-mutated document, as will the index.
Signed-off-by: quobix <dave@quobix.com>
And added deeper support for Aliases. Also added in local file handling through renamed `FSHandler` configuration property for the index.
Also re-ran `go fmt`
Signed-off-by: Dave Shanley <dave@quobix.com>
A new configuration option is available to the index, a `RemoteHandler` of type `fs.FS`. If set, will be used as an override to all other remote fetching code.
Signed-off-by: Dave Shanley <dave@quobix.com>
In vacuum, a usecase was reported where an infinite loop occurred due to re-parsing the same reference over and over in a loop. It was re-creatable and it was because the loop happened before the index was ready.
This should be resolved now, at least for this use case. To be sure, I have included the specs as a new test.
https://github.com/daveshanley/vacuum/issues/268
Signed-off-by: Dave Shanley <dave@quobix.com>
When remote documents are requested and there is no way to know the base URL, the index will now try and determine the base path from the way the spec was loaded (if it comes in remote, we use the base URL of the spec)
Different race conditions popped up at different times, depending on how complex the nesting of indexes was. After running tests with `-race` I've knocked out all the concurrency issues being reported and now there are no race conditions reported by the tests. This should knock out all known race conditions with some targeted mutex locks.
Non breaking change.
The index runs async everywhere, it's kinda impossible to know which path with resolve first, so testing is hard. Sometimes a race condition is hit, well, it was. Now that map has a mutex on it.
Also fully fixed handling files with relative links. A basepath property has been added to the index configuration to allow a local root to be set when resolving files.
Added a full checkout test for digital ocean so that full remote and full local testing is performed.
This partially resolves a whacky path ref lookup in the index mentioned in #84, but it's not a full fix, that requires the build out of a resolved spec. The design needs thought and care.
Tests all passing, runs super fast, pulls in every single DigitalOcean spec and parses it. There may be some issues deeper down in the models, but for now high level tests all pass.