feat(validator): add CUE file validation support#467
Conversation
|
@mvanhorn Please try to limit the amount of PR's to one or two at a time. Especially when the previous ones have undressed issues. |
kehoecj
left a comment
There was a problem hiding this comment.
@mvanhorn Implementation is solid and passed against a set of real cue files. A few things to clean up before merging (I'm going to assume KDL goes before this one):
- CHANGELOG entry
- Rebase. Your branch is downgrading several dependencies because it's based off an older main. After rebasing, run
go get cuelang.org/go@v0.16.1thengo mod tidy. This will also pull in my docs update. - The current dependency is a dev pre-release (
v0.17.0-0.dev.0.20260319...). I checked andv0.16.1(latest stable) has the same parser.ParseFile API. Please usecuelang.org/go v0.16.1instead. - Docs updates:
- website/docs/reference/supported-file-types.md: Add cue
- website/docs/introduction.md: update format count from 17 -> 18
- README.md: update format count from 17 -> 18 and add cue
CUE (Configure, Unify, Execute, https://cuelang.org) is a typed configuration language increasingly used for Kubernetes, OPA, and config DSLs. Add a syntax-only CUE validator wired into the existing FileType registry. - New CueValidator in pkg/validator/cue.go calls cuelang.org/go/cue/parser.ParseFile. Errors are surfaced as cueerrors.Error so consumers see CUE's structured diagnostics. - New CueFileType in pkg/filetype with the .cue extension. Added to fileTypeRegistry and the FileTypes slice. - Two table-driven test cases (valid + invalid CUE). - README format count bumped from 16 to 17 to reflect the new validator. - CHANGELOG entry under Unreleased / Added referencing Boeing#462. Per review feedback (@kehoecj): - Rebased on current main (go.sum conflict resolved). - Switched cuelang.org/go from the dev pre-release (v0.17.0-0.dev.0...) to the latest stable v0.16.1, which exposes the same parser.ParseFile API. go mod tidy applied. Closes Boeing#462 Signed-off-by: Matt Van Horn <mvanhorn@gmail.com>
aab5e09 to
a650a72
Compare
|
Thanks @kehoecj. Pushed a650a72:
The
|
| </p> | ||
|
|
||
| Config File Validator validates config files across 16 formats. | ||
| Config File Validator validates config files across 17 formats. |
There was a problem hiding this comment.
| Config File Validator validates config files across 17 formats. | |
| Config File Validator validates config files across 18 formats. |
|
@mvanhorn KDL was merged, please resolve conflicts and bump count to 18. Thanks! |
Summary
Adds syntax validation for CUE (
.cue) files using the officialcuelang.org/goSDK. CUE is gaining traction in the Kubernetes / DevOps ecosystem (Dagger, KubeVela), and the issue specifically calls out the pure-Go SDK as the right entry point.What changed
pkg/validator/cue.go— new file.CueValidatorwrapscue/parser.ParseFileand returnsValidationError{Err, Line, Column}when the parse fails. Mirrors the position-extraction pattern inTomlValidator(pkg/validator/toml.go:11).pkg/filetype/file_type.go— newCueFileType(extensioncue), registered infileTypeRegistryand added to theFileTypesslice ininit()so the file is dispatched to the new validator.pkg/validator/validator_test.go—validCueandinvalidCuecases added to the existingtestDataslice..pre-commit-hooks.yaml—cueadded to bothtypes_orand thefilesregex on theconfig-file-validatorhook so that changed.cuefiles actually invoke the validator under the standard pre-commit integration. (Without this, the hook's type filter would silently skip.cuefiles even though the validator is registered.)go.mod/go.sum— addscuelang.org/goand its transitive dependencies viago get+go mod tidy.68 lines added, 19 removed (the bulk of
go.sumaccounts for the rest).Verification
go build ./...— passgo vet ./...— passgo test ./pkg/validator/... ./pkg/filetype/...— passScope notes
SchemaValidatoronCueValidator. This PR is the syntax-only foundation called out in the issue.Closes #462
This contribution was developed with AI assistance.