chore(installation): early validate presence of tag in image and imageRepository#6354
Conversation
671cb4f to
bb71c3a
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6354 +/- ##
==========================================
- Coverage 70.82% 70.82% -0.01%
==========================================
Files 220 220
Lines 37132 37132
==========================================
- Hits 26300 26299 -1
Misses 9293 9293
- Partials 1539 1540 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
bb71c3a to
c0fdbf5
Compare
|
can this be solved with CEL ? so the user hit this error during apply and won't have to find the error in logs |
c0fdbf5 to
8ca03db
Compare
Updated with CEL validation |
db914a4 to
2b57d13
Compare
api/v1alpha1/shared_types.go
Outdated
There was a problem hiding this comment.
| // +kubebuilder:validation:XValidation:rule="has(self.image) ? self.image.matches('^[^:]+:[^:]+$') : true",message="Image must include a tag (e.g., 'image:tag')." | |
| // +kubebuilder:validation:XValidation:rule="self.image.matches('^[a-zA-Z0-9._/-]+:[a-zA-Z0-9._-]+$') : true",message="Image must include a tag and allowed characters only (e.g., 'image:tag')." |
Added some suggestions to make regex stricter, let me know what you think! Also can we remove has checks and move them to the respective fields, so kube validations apply on non-null values of the fields only?
There was a problem hiding this comment.
Stricter regex sounds good!
can we remove has checks and move them to the respective fields
Yeah, moving validation to the respective field will be a cleaner approach, but we wont be able to provide a custom message. But a generic message would be fine, I guess.
There was a problem hiding this comment.
Well, the generic message does not look very good. Let me know your thougts
EnvoyProxy.gateway.envoyproxy.io "proxy-1750699777609469000" is invalid: spec.provider.kubernetes.envoyDeployment.container.image: Invalid value: "envoyproxy/envoy": spec.provider.kubernetes.envoyDeployment.container.image in body should match '^[a-zA-Z0-9._/-]+:[a-zA-Z0-9._-]+$'
There was a problem hiding this comment.
@sudiptob2 can we do something like this?
gateway/api/v1alpha1/shared_types.go
Line 339 in ddc9a5c
api/v1alpha1/shared_types.go
Outdated
There was a problem hiding this comment.
| // +kubebuilder:validation:XValidation:rule="has(self.imageRepository) ? !self.imageRepository.contains(':') : true",message="ImageRepository must not include a tag or any colons." | |
| // +kubebuilder:validation:XValidation:rule="self.imageRepository.matches('^[a-zA-Z0-9._/-]+$')",message="ImageRepository must include allowed characters only and not include a tag or any colons." |
40f0a49 to
0086edd
Compare
…mageRepository` field in KubernetesContainerSpec Signed-off-by: sudipto baral <sudiptobaral.me@gmail.com>
…epository Signed-off-by: sudipto baral <sudiptobaral.me@gmail.com>
Signed-off-by: sudipto baral <sudiptobaral.me@gmail.com>
Signed-off-by: sudipto baral <sudiptobaral.me@gmail.com>
0086edd to
c53ec24
Compare
|
/retest |
1 similar comment
|
/retest |
PR #6296 added support for customizing the EnvoyProxy image using the
imageandimageRepositoryfields. In summary:image: repo:tag. This has been the standard approach in all versions up to this PR.imageRepository: repo_url.To ensure these fields are used correctly, it's helpful to validate the presence or absence of a tag depending on which field is set.
This PR improves the(5a85f82)resolveProxyImagefunction by adding the following validations:This PR adds following CEL validation:
imageRepositoryis set, it must not include a tag.imageis set, it must include a valid tag.Idea for more validation logic is appreciated.
Fixes #6350