Closed jefflill closed 2 years ago
FYI: I have a class that handles serialization for GOLANG durations (at least how I understand that they work):
https://github.com/nforgeio/neonKUBE/blob/master/Lib/Neon.Common/Time/GoDuration.cs
Hey @jefflill,
Yes, currently there is no [Ignore]
attribute. It seems that this would be a good addition.
Currently only scalar and string types are allowed in CRDs since it must be representable in yaml. However, an idea would be to have an ignore attribute and a "converter function" attribute, which must return a scalar type.
I just finished coding the get/set method approach which is working OK. The [Ignore]
attribute would probably be easy to implement, but it won't play well with ASPNET JsonPatchDocument
class, so I'm not sure how much help.
The ideal solution would be a converter function like you suggest.
It might be worth thinking about baking in a solution for TimeSpan
because I image that this will be quite common.
While that may be true, I'd like to stick to the standard. When we diverge from the standards that are implemented in Kubernetes, every change from K8S may result in a break.
I think the Ignore and Converter attributes are the way to go.
I agree. I just re-read the API conventions and they explicitly say it's best to encode durations as seconds or something rather than requiring that programs in other languages be able to parse golang durations.
Is your feature request related to a problem? Please describe. I'd like to add
TimeSpan
properties my custom resource spec and status properties. This isn't supported out of the box:I was hoping to define
TimeSpan
properties with a type converter that converted to/from GOLANG duration format, butTimeSpan
isn't supported at all.As a workaround, I thought I could define the CRD properties as strings and then add hidden properties that did the conversion to/from the string properties, something like:
This wouldn't actually be too bad, but KubeOps has no
[IgnoreProperty]
attribute that I can see.My next workaround is to add
GetTimeout()
andSetTimeout()
methods (not horrible, but feels like Java).Describe the solution you'd like
TimeSpan
properties natively by parsing GOLANG style durations[IgnoreProperty]
attribute