Skip to content

Conversation

@IfSentient
Copy link
Contributor

What Changed? Why?

[codegen] Allow GoTypes Jenny to have a configurable set of fields to exclude from generation when Depth > 0, and exclude the metadata field from generation using this behavior in the go resource generator. The metadata type is not used and can cause confusion for users, as it is a merge of the kubernetes object metadata and the custom metadata fields which are set as annotations in the actual object type. It was previously generated for compliance with the Thema model, which is no longer an option when generating code.

How was it tested?

Tested with make generate in a test project, as well as updating the existing unit tests.

Where did you document your changes?

Updated the tutorial doc to remove references to the metadata type, as that appears to be the only place it's referenced.

Notes to Reviewers

… exclude from generation when Depth > 0, and exclude the metadata field from generation using this behavior in the go resource generator.
@IfSentient IfSentient requested a review from a team as a code owner November 17, 2025 15:33

//nolint:goconst
func (g *GoTypes) generateFilesAtDepth(v cue.Value, kv *codegen.KindVersion, currDepth int, machineName string, packageName string, pathPrefix string, namePrefix string) (codejen.Files, error) {
func (g *GoTypes) generateFilesAtDepth(v cue.Value, kv *codegen.KindVersion, currDepth int, machineName string, packageName string, pathPrefix string, namePrefix string, excludeNames []string) (codejen.Files, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit; consistent naming

Suggested change
func (g *GoTypes) generateFilesAtDepth(v cue.Value, kv *codegen.KindVersion, currDepth int, machineName string, packageName string, pathPrefix string, namePrefix string, excludeNames []string) (codejen.Files, error) {
func (g *GoTypes) generateFilesAtDepth(v cue.Value, kv *codegen.KindVersion, currDepth int, machineName string, packageName string, pathPrefix string, namePrefix string, excludeFields []string) (codejen.Files, error) {

}
}
if exclude {
return nil, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit; generally speaking it is best to return an sentinel error along with a nil return.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants