Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
justinsb opened this issue May 20, 2024 · 1 comment
Open

Comments

@justinsb
Copy link
Contributor

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
@sbueringer
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants