dotnet-operator-sdk
dotnet-operator-sdk copied to clipboard
[bug]: Length attribute with maxLength not filled generates incorrect OpenApiSpec
Describe the bug
When creating a CRD entity, the Length attribute has -1 as default value for minimum and maximum length. These values are then converted to null when read from the property. But when serializing the constraint into a Kubernetes resource, not filled values are rendered as -1.
See below a sample of [Length(minLength: 1)] public string Name { get; set; } = string.Empty; gets rendered:
I suspect not filling minLength will render to something similarly wrong...
To reproduce
- Generate a new empty operator
- Create a new custom kubernetes entity having its spec something like
public class EntitySpec { [Length(minLength: 1)] public string Name { get; set; } = string.Empty; } - Compile the project
- Check the generated resource yaml
Expected behavior
The generated spec for the property should look like:
name:
minLength: 1
nullable: false
type: string
Screenshots
No response
Additional Context
No response