-
Notifications
You must be signed in to change notification settings - Fork 14
feat(validate): structured results and --output json|yaml flag #66
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
15da6fb
feat(validate): structured results and --output json|yaml flag
jcogilvie e0c9dc0
fix(validate): preserve historical defaulting-failure semantics
jcogilvie 050dafc
refactor(validate): address PR #1 review feedback
jcogilvie d192b93
refactor(validate): inject Renderer via Kong's MapperValue interface
jcogilvie e7ff988
refactor(validate): move pkg/validate to top level, rename render→output
jcogilvie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
25 changes: 25 additions & 0 deletions
25
...validate/testdata/cache/xpkg.crossplane.io/crossplane/crossplane@v0.0.0-test/package.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| apiVersion: apiextensions.k8s.io/v1 | ||
| kind: CustomResourceDefinition | ||
| metadata: | ||
| name: testbuiltins.test.crossplane.io | ||
| spec: | ||
| group: test.crossplane.io | ||
| names: | ||
| kind: TestBuiltin | ||
| listKind: TestBuiltinList | ||
| plural: testbuiltins | ||
| singular: testbuiltin | ||
| scope: Cluster | ||
| versions: | ||
| - name: v1alpha1 | ||
| served: true | ||
| storage: true | ||
| schema: | ||
| openAPIV3Schema: | ||
| type: object | ||
| properties: | ||
| spec: | ||
| type: object | ||
| properties: | ||
| foo: | ||
| type: string |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| apiVersion: apiextensions.k8s.io/v1 | ||
| kind: CustomResourceDefinition | ||
| metadata: | ||
| name: tests.cmd.example.org | ||
| spec: | ||
| group: cmd.example.org | ||
| names: | ||
| kind: Test | ||
| listKind: TestList | ||
| plural: tests | ||
| singular: test | ||
| scope: Cluster | ||
| versions: | ||
| - name: v1alpha1 | ||
| served: true | ||
| storage: true | ||
| schema: | ||
| openAPIV3Schema: | ||
| type: object | ||
| properties: | ||
| spec: | ||
| type: object | ||
| required: | ||
| - replicas | ||
| properties: | ||
| replicas: | ||
| type: integer |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| apiVersion: cmd.example.org/v1alpha1 | ||
| kind: Test | ||
| metadata: | ||
| name: bad-instance | ||
| spec: | ||
| replicas: "not-an-int" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| apiVersion: nosuch.example.org/v1 | ||
| kind: Unknown | ||
| metadata: | ||
| name: missing-schema |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| apiVersion: cmd.example.org/v1alpha1 | ||
| kind: Test | ||
| metadata: | ||
| name: ok-instance | ||
| spec: | ||
| replicas: 3 |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused constant:
errWriteOutputis defined but never referenced.Thanks for the thoughtful organization here! I notice this constant is declared but the actual error wrapping on line 166 uses a different string (
"cannot render validation result"). Could you clarify whether this constant was intended to be used there, or should it be removed as dead code?🧹 Suggested fix: either use the constant or remove it
Option A — use the constant:
Option B — remove the unused constant:
📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skipping this one —
errWriteOutputis used inmanager.go:315(the "schemas does not exist, downloading: ..." Fprintln wrap), so removing it would break the build. The constant lives incmd.gobecause the prior monolithicvalidate.gowas where it was originally declared;cmd.gois now the only top-level non-test file in the package, hence the placement. Happy to move it to a dedicatederrors.goif you'd prefer it not appear adjacent to a Cmd that doesn't use it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Length of output: 1221
@jcogilvie, you're absolutely right — confirmed inmanager.go:315:My apologies for the false positive! I missed the cross-file usage within the same package. The placement in
cmd.goas the package's sole non-test top-level file makes complete sense, and no change is needed here. Thanks for the clear explanation!🧠 Learnings used