client deserialization <-> validation webhook deserialization #1683
Unanswered
kimpenhaus
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone,
I’m facing the following issue:
I’m using a CRD model that has a property of type TimeSpan. As far as I understand, this should follow the ISO 8601 duration format.
This is enforced by the TimeSpanConverter in KubernetesJson, which works well — serialization and deserialization both behave as expected. (e.g.
PT1H)sample within linqpad:
Now, we’re using the .NET Operator SDK and with that its validation webhooks. My understanding is that since there’s no custom model binder provided in the operator sdk, the deserialization there happens via
System.Text.Jsonby default.And that’s where the problem arises:
TimeSpanis not expected in ISO 8601 format here, but instead in the standard timespan format.My idea was to use a custom model binder in the Operator SDK that uses the same deserialization mechanism as the KubernetesClient — which, in my opinion, makes perfect sense since both should behave consistently.
Now to my actual question: as far as I know, a model binder cannot be generic.
However, the target type is available in the model binder context.
To use the same mechanism as the KubernetesClient, I would need a non-generic Deserialize(Type type, ...) method — but KubernetesJson only exposes generic methods.
Is there any non-generic way to achieve this? What would be the recommended approach here?
Alternatively, would it be possible to add a non-generic Deserialize method to KubernetesJson?
And lastly, is the KubernetesJson class actually recommended for use in this context?
Thanks for your feedback!
Beta Was this translation helpful? Give feedback.
All reactions