Classify K8sResource using x-kubernetes-group-version-kind#20
Merged
petermorrowdev merged 11 commits intomainfrom Feb 25, 2025
Merged
Classify K8sResource using x-kubernetes-group-version-kind#20petermorrowdev merged 11 commits intomainfrom
K8sResource using x-kubernetes-group-version-kind#20petermorrowdev merged 11 commits intomainfrom
Conversation
Allowing for objects without fields like `status` and `spec`
`kubectl` does not accept these objects in `kind: ...`
K8sResource to add missing
I didn't see the x-kubernetes-group-version-kind attribute when I wrote codegen first. Using this attribute is the more correct and clean approach.
- The can't be created, can cause confusion - The feel unnecessary
- Extracts directory paths as function arguments with defaults
- Write tests for here later
K8sResource to add missingK8sResource using x-kubernetes-group-version-kind
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.
My first method for classifying
K8sResourcewas by inferring based on model properties. This method missed some kubernetes resources, likeControllerRevision. Looking more closely at the OpenAPI spec I found there's these x-kubernetes-group-version-kind attributes that identify all k8s resources deterministically.This PR switches to this new mechanism. It also includes explicit testing for codegen using static OpenAPI specs copied into the repo from kubernetes version history.
This change also highlighted how many k8s objects there were ending in "List." These objects are only used in responses and are redundant in a type system with generics, so I decided to remove them. They are most likely unused by existing users.