kubernetes-sigs/controller-tools

kubebuilder:validation:Format should apply to array items, not to array

justinsb opened this issue · 3 comments

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

I think the current behavior is correct. See also: #342

Since #898 it's now possible to define markers directly on the slice items via e.g. // +kubebuilder:validation:items:MinLength=1

/close

See above. Feel free to reopen if necessary

@sbueringer: Closing this issue.

In response to this:

/close

See above. Feel free to reopen if necessary

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.