Add Go config validator (ported from @andylockran's work)#1
Open
outofcoffee wants to merge 8 commits into
Open
Add Go config validator (ported from @andylockran's work)#1outofcoffee wants to merge 8 commits into
outofcoffee wants to merge 8 commits into
Conversation
Builds on andylockran's ported validator and brings it up to the level
needed to serve as the shared validation library for the Imposter CLI's
validate subcommand:
- Initialise a standalone Go module (github.com/imposter-project/specification).
- Embed the schema files via go:embed (schema package) so the validator
is self-contained and needs no schema files on disk.
- Extract the logic into an importable validator package exposing
Validate{Value,File,Dir}; cmd/validate-configs becomes a thin CLI.
- Validate each document against the current OR legacy format, resolving
the shared-definitions.json references in-memory.
- Support multi-document YAML and exit non-zero on failure for CI use.
- Add unit tests for the validator package.
The original package-main test is superseded by the validator package
tests.
Adds a Go job to the validate-configs workflow that runs the unit tests and validates the imposter-project/examples configs with the Go validator (alongside the existing Python job). Documents the Go tool and its use as an importable library.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports the Go-based config validator from @andylockran's
imposter-go#3 into this
repository and brings it up to the level needed to serve as the shared
validation library for the Imposter CLI's
validatesubcommand(imposter-cli#122).
Andy's original commits are replayed here with his authorship and dates
intact so his work is clearly the basis of this validator. Please merge with a
merge commit or rebase (not squash) so those commits are preserved in history.
Andy's commits (the port)
The first six commits are @andylockran's, replaying his Go validator (placed
under
cmd/validate-configs/):Improvements on top
Built on Andy's port so the validator can be embedded in the Imposter CLI:
module github.com/imposter-project/specification.go:embed(theschemapackage), so the validator is self-contained and needs no schemafiles on disk (Andy raised this in the original PR).
validatorpackage exposingValidate{Value,File,Dir};cmd/validate-configsis now a thin CLI. This iswhat imposter-cli will depend on for
imposter validate.legacy format, resolving the
shared-definitions.jsonreferences in-memory.validatorpackage, plus a CI job that runs the tests andvalidates the
imposter-project/examplesconfigs with the Go validator.Notes
claude/imposter-schema-consolidation-trgbhzbranch, which movesthe schema + Python validator into this repo and extends the schema to cover
all official examples. This PR targets that branch.
go test ./...passes and the Go validator validates all 69 example configs.Generated by Claude Code