Pydantic type representing meta Duration
What is the feature and why do you need it: The Pydantic dependency in 37.0.0 made it possible to define custom models to represent custom resources.
In release 37 a Pydantic model representing custom objects can be defined and via model_dump/model_verify can be passed through the CustomObjectsApi.
A number of these use types not available in the K8s API such a metav1.Duration such as in Velero. This gets serialized to and from openapi spec string to the struct by golang and as such cannot be easily handled via openapi spec.
Before the Pydantic incorporation in 37 there was not a possibility to add in custom models compatible with the Python k8s client parser.
Describe the solution you'd like to see: A Pydantic meta Duration type that serializes/deserializes such an object.
Typehinting of the kubernetes.util.duration functions.
/help
@yliaog: This request has been marked as needing help from a contributor.
Guidelines
Please ensure that the issue body includes answers to the following questions:
- Why are we solving this issue?
- To address this issue, are there any code changes? If there are code changes, what needs to be done in the code and what places can the assignee treat as reference points?
- How can the assignee reach out to you for help?
For more details on the requirements of such an issue, please see here and ensure that they are met.
If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help command.
In response to this:
/help
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
@msfrucht are you still planning to come back to this after the CLA? If not, I'm happy to pick it up.
Since metav1.Duration in the K8s API maps to a string in the OpenAPI spec, should this Pydantic model implement a __get_pydantic_core_schema__ using Annotated with BeforeValidator to handle the string-to-timedelta conversion during model_validate?
No reply so far, so I'll take this one. PR soon.
/assign @chala2001