Add [IgnorePropertyAttribute] that ignores a property when generating CRDs or support TimeSpan properties
See original GitHub issueIs 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:
[KubeOps.Operator.Errors.CrdConversionException]: During conversion of the property "Spec" with type "TaskSpec", an error occured. [inner:KubeOps.Operator.Errors.CrdConversionException: During conversion of the property "RetentionTime" with type "TimeSpan", an error occured.]
I was hoping to define TimeSpan
properties with a type converter that converted to/from GOLANG duration format, but TimeSpan
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:
public class MySpec
{
public string Timeout { get; set;}
[IgnoreProperty]
public TimeSpan TimeoutTimeSpan
{
get => GoDuration.Parse(Timeout);
set => Timeout = GoDuration.FromTimeSpan(value).ToString();
}
}
This wouldn’t actually be too bad, but KubeOps has no [IgnoreProperty]
attribute that I can see.
My next workaround is to add GetTimeout()
and SetTimeout()
methods (not horrible, but feels like Java).
Describe the solution you’d like
- Ideally, KubeOps could handle
TimeSpan
properties natively by parsing GOLANG style durations - Add and implement an
[IgnoreProperty]
attribute
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Azure.Data.Tables doesn't honour IgnorePropertyAttribute
It seems that the attribute IgnorePropertyAttribute should be used to decorate the properties to ignore. However this attribute is in a ...
Read more >IgnorePropertyAttribute Class (Microsoft.Azure.Cosmos. ...
Represents a custom attribute that can be used to ignore entity properties during serialization/de-serialization.
Read more >Ignore property attribute · Issue #678 · Azure/azure-cosmos ...
My collection is schema-free for example, I have a string property called "visit_history" but it stores as serialized string format value ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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.