Skip to content

Add Go config validator (ported from @andylockran's work)#1

Open
outofcoffee wants to merge 8 commits into
claude/imposter-schema-consolidation-trgbhzfrom
validate-config-go
Open

Add Go config validator (ported from @andylockran's work)#1
outofcoffee wants to merge 8 commits into
claude/imposter-schema-consolidation-trgbhzfrom
validate-config-go

Conversation

@outofcoffee

Copy link
Copy Markdown
Contributor

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 validate subcommand
(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/):

  • Tests required, but python-equivalent script in golang to stretch golang muscles
  • Updated script for ease of read
  • Working on adding some tests
  • Updated tests
  • Breaking up the logic
  • Update README.md

Improvements on top

Built on Andy's port so the validator can be embedded in the Imposter CLI:

  • Standalone modulemodule github.com/imposter-project/specification.
  • Embedded schema — the schema files are embedded via go:embed (the
    schema package), so the validator is self-contained and needs no schema
    files on disk (Andy raised this in the original PR).
  • Importable library — the logic lives in the validator package exposing
    Validate{Value,File,Dir}; cmd/validate-configs is now a thin CLI. This is
    what imposter-cli will depend on for imposter validate.
  • Current or legacy — each document is validated against the current or
    legacy format, resolving the shared-definitions.json references in-memory.
  • Multi-document YAML and non-zero exit on failure for CI use.
  • Unit tests for the validator package, plus a CI job that runs the tests and
    validates the imposter-project/examples configs with the Go validator.

Notes

  • Based on the claude/imposter-schema-consolidation-trgbhz branch, which moves
    the 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

andylockran and others added 8 commits January 8, 2025 21:45
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.
@outofcoffee outofcoffee self-assigned this Jun 11, 2026
@outofcoffee outofcoffee added the enhancement New feature or request label Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants