Skip to content

Classify K8sResource using x-kubernetes-group-version-kind#20

Merged
petermorrowdev merged 11 commits intomainfrom
feature/loosen-k8s-resource-requirements
Feb 25, 2025
Merged

Classify K8sResource using x-kubernetes-group-version-kind#20
petermorrowdev merged 11 commits intomainfrom
feature/loosen-k8s-resource-requirements

Conversation

@petermorrowdev
Copy link
Owner

@petermorrowdev petermorrowdev commented Feb 19, 2025

My first method for classifying K8sResource was by inferring based on model properties. This method missed some kubernetes resources, like ControllerRevision. 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.

Allowing for objects without fields like `status` and `spec`
`kubectl` does not accept these objects in `kind: ...`
@petermorrowdev petermorrowdev changed the title Include missing k8s resources Expand definition of K8sResource to add missing Feb 21, 2025
@petermorrowdev petermorrowdev marked this pull request as ready for review February 21, 2025 06:20
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
@petermorrowdev petermorrowdev changed the title Expand definition of K8sResource to add missing Classify K8sResource using x-kubernetes-group-version-kind Feb 25, 2025
@petermorrowdev petermorrowdev merged commit a4c76f0 into main Feb 25, 2025
1 check passed
@petermorrowdev petermorrowdev deleted the feature/loosen-k8s-resource-requirements branch February 25, 2025 04:55
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.

1 participant