Our goal is to be able to provide schemas that we've compiled to the validator, in order to prevent needing to read/write to a cache on the filesystem.
Context: We're distributing a command line tool that will generate k8s manifests for various projects, and would like it to work in an offline environment. Rather than distribute the schemas separately from the tool, we plan to embed them in the binary with go:embed. We could dump them to disk and then provide that path to the validator constructor, but we'd rather skip the middleman and just provide the schemas directly.
The approach we were thinking of would be to support passing in a pre-populated inMemory Cache via Opts, and setting that on the validator in New. If that doesn't sound too bad, I can put together a pull request for it.
edit: another alternative approach would be to allow providing a Registry implementation that would take precedence over the others so that we could provide our schemas if they're present in the project. That feels like it might be slightly nicer, but is a bit more complex.
Our goal is to be able to provide schemas that we've compiled to the validator, in order to prevent needing to read/write to a cache on the filesystem.
Context: We're distributing a command line tool that will generate k8s manifests for various projects, and would like it to work in an offline environment. Rather than distribute the schemas separately from the tool, we plan to embed them in the binary with go:embed. We could dump them to disk and then provide that path to the validator constructor, but we'd rather skip the middleman and just provide the schemas directly.
The approach we were thinking of would be to support passing in a pre-populated inMemory Cache via Opts, and setting that on the validator in New. If that doesn't sound too bad, I can put together a pull request for it.
edit: another alternative approach would be to allow providing a Registry implementation that would take precedence over the others so that we could provide our schemas if they're present in the project. That feels like it might be slightly nicer, but is a bit more complex.