flux2
flux2 copied to clipboard
Review and enforce CRD Validation
In the run-up to maturing flux APIs, we should review all CRD validation and ensure that they align with expected input.
Controllers:
- [ ] source-controller
- [ ] kustomize-controller
- [ ] helm-controller
- [ ] notification-controller
- [ ] image-reflector-controller
- [ ] image-automation-controller
Additional points to consider:
- Use kubebuilder validation and add tests, as per https://github.com/fluxcd/helm-controller/pull/520.
.Specfields should be marked as required across all CRDs.- String fields should have a max length and pattern defined (when possible).
- We should use reference types from pkg, and also improve its current validation: https://github.com/fluxcd/pkg/blob/main/apis/meta/reference_types.go
Hey @pjbgf I would like work on this. I am not sure about couple of points, can you please clarify:
- Point 1: The validation and tests needs to be added to
ValueKeyandTargetPathfields only? - Point 2: Got it
- Point3: max length and patterns be defined on reference types from pkg linked in Point 4?
@Santosh1176 here's more info:
- The PR was just an example on how to implement the validation, as in added via
+kubebuilder:validationand then tested with testenv. We need to review each CRD for all controllers, and make sure that all fields are validated. - OK
- The validation will depend on each field at hand, so may need some research on how that field is being used, and what rules it has to abide by.
- Those reference types at the moment only have
+required, they lack max length and pattern validation. In some CRD we may be using other types instead of them to refer to Kubernetes objects, when that's the case we must change that.
@pjbgf Any reference/guidance for max and min length properties for strings fields?
@Santosh1176 unfortunately this will be on a case-by-case basis. Feel free to propose some validation for one of the CRDs and during the review we will provide you with some feedback.
@Santosh1176 I am interested contributing to this issue as well, have you made any progress since?
What about I take one of those task item? for example, the notification controller?
Cheers.