-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Why doesn't the API provide default values for ApiVersion and Kind? #3858
Comments
All of these API objects are code generated from the OpenAPI specification: https://github.com/kubernetes/kubernetes/blob/master/api/openapi-spec/README.md There are no default values specified in that specification and thus there's no default values that the code generator knows how to insert. You could probably write a utility method which heuristically guesses at it using the class name and reflection
|
There is nothing wrong with using code generators, but when their limitations hurt usability... it's a problem. I also noticed that many resources have identical methods but no common supertype. This makes it much harder for users to write their own helper methods because now they have to repeat the same code over and over again once per resource type. Yes, users can generate utility methods but it would be much cheaper (many users, fewer developers) to fix it inside the library than make everyone write their own helpers outside it. Is this something that can be improved? |
The API surface area is so large and changes constantly which means that code generation is the only way to keep up with API surface area. So using a code generator is a hard requirement for this project (and all of the Kubernetes clients except Golang) There are four ways that you can improve things:
In the specific case of this issue, I think it could be fixed by 1) adding default values to that openapi/swagger doc. You might have to also do 2) if defaults aren't currently supported by the code generator. There might be other things that you can think of as well, we're always open to PRs to fix things. |
Describe the bug
When I am constructing a
V1ConfigMap
orV1Job
I believe there is only one reasonable value that can be assigned to theApiVersion
andKind
properties, so why does the API force users to fill these in by hand every time? Can't the API populate these default values for us when we construct a new instance?The text was updated successfully, but these errors were encountered: