controller-tools
controller-tools copied to clipboard
kubebuilder:validation:Format should apply to array items, not to array
This is likely a regression / reoccurence of an issue that was originally raised in #141 and fixed in #143, but was broken by refactoring accompanied by removal of the test cases (which would have prevented regression). As such I don't believe the regression is deliberate, although I'm not 100% certain of the correct behaviour.
I have tried to add test cases to show the issue in #952 (based on the original test cases). I believe the format directive should apply to the item, not the slice. To cite the problem from #952 so that we can first agree that the current behaviour is wrong:
// +kubebuilder:validation:Format=ipv4
Addresses []string `json:"addresses"`
Currently this produces:
+ addresses:
+ format: ipv4
+ items:
+ type: string
+ type: array
I believe it should produce:
+ addresses:
+ items:
+ format: ipv4
+ type: string
+ type: array