Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support providing preloaded schemas #215

Open
tmcg-gusto opened this issue Jun 28, 2023 · 1 comment · May be fixed by #216
Open

Support providing preloaded schemas #215

tmcg-gusto opened this issue Jun 28, 2023 · 1 comment · May be fixed by #216

Comments

@tmcg-gusto
Copy link

tmcg-gusto commented Jun 28, 2023

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.

@tmcg-gusto tmcg-gusto linked a pull request Jun 29, 2023 that will close this issue
@tmcg-gusto
Copy link
Author

Ended up going with the alternative approach of providing a custom Registry as it ended up being a simpler approach on our end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant