Skip to content

Support providing preloaded schemas #215

@tmcg-gusto

Description

@tmcg-gusto

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions