feat: Add TableColumns to resource.Schema with codegen support#1299
Open
IfSentient wants to merge 1 commit intomainfrom
Open
feat: Add TableColumns to resource.Schema with codegen support#1299IfSentient wants to merge 1 commit intomainfrom
IfSentient wants to merge 1 commit intomainfrom
Conversation
Extends resource.Schema with TableColumns() method providing type-safe column accessors for kubectl table display, eliminating the need for reflection-based JSONPath resolution. Changes: - Added TableColumn type to resource/schema.go with ValueFunc for direct field extraction - Extended Schema interface with TableColumns() method, implemented on SimpleSchema - Added WithTableColumns() option for SimpleSchema configuration - Implemented getTableColumns() in codegen/jennies/schema.go to validate and generate table column metadata from CUE AdditionalPrinterColumns - Updated schema.tmpl to generate WithTableColumns() calls with type-safe closures - Rewrote k8s/apiserver/tableconvertor.go to use Schema TableColumns exclusively, removed all reflection code - Simplified storage.go to read columns from kind.TableColumns() directly - Added example AdditionalPrinterColumns to apiserver example - Added comprehensive tests and kubeconfig for local apiserver testing This follows the same pattern as SelectableFields, providing codegen-generated type-safe accessors instead of reflection. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
IfSentient
commented
Mar 18, 2026
| routes: namespaced: { | ||
| "/foobar": { | ||
| "GET": { | ||
| name: "getFoobar" |
Contributor
Author
There was a problem hiding this comment.
Drive-by to fix codegen, as name is now required for all routes.
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.
What Changed? Why?
Extended
resource.Schemawith aTableColumns()method that provides type-safe column accessors forkubectl gettable display, eliminating the need for reflection-based JSONPath resolution.Why: Previously, the apiserver's TableConverter was always the default k8s one, and the fields in
AdditionalPrinterColumnswere ignored. This change unifies the behavior of an apiserver app with that of one which uses CRDs.How was it tested?
AdditionalPrinterColumnsto apiserver example kind (TestKind.v1alpha1)WithTableColumns()with correctValueFuncclosuresAlso tested that the
examples/apiserverreturned the new column in the table view viewkubectl --kubeconfig=kubeconfig get testkindsWhere did you document your changes?
examples/apiserver/README.mdwith kubectl usage examplesTableColumnstructNotes to Reviewers
resource.Schemainterface (addsTableColumns()method). Given the SDK is v0.x/experimental, this is acceptable.getTableColumns()duplicates some validation logic fromgetSelectableFields()(JSONPath parsing, CUE lookup). This could be extracted to a shared helper in a follow-up.Co-authored by claude code