-
Notifications
You must be signed in to change notification settings - Fork 380
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
CEL validation: implement validateProvider for EnvoyProxy #2081
Conversation
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Codecov Report
@@ Coverage Diff @@
## main #2081 +/- ##
==========================================
- Coverage 64.56% 64.48% -0.08%
==========================================
Files 109 109
Lines 15049 15049
==========================================
- Hits 9716 9705 -11
- Misses 4735 4742 +7
- Partials 598 602 +4
|
Signed-off-by: zirain <zirain2009@gmail.com>
@@ -122,6 +122,9 @@ type EnvoyProxyKubernetesProvider struct { | |||
// are applied. | |||
// | |||
// +optional | |||
// +kubebuilder:validation:XValidation:message="allocateLoadBalancerNodePorts can only be set for LoadBalancer type",rule="!has(self.allocateLoadBalancerNodePorts) || self.type == 'LoadBalancer'" | |||
// +kubebuilder:validation:XValidation:message="loadBalancerIP can only be set for LoadBalancer type",rule="!has(self.loadBalancerIP) || self.type == 'LoadBalancer'" | |||
// +kubebuilder:validation:XValidation:message="loadBalancerIP must be a valid IPv4 address",rule="!has(self.loadBalancerIP) || self.loadBalancerIP.matches(r\"^(((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.|$)){4})\")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this's hard to read, but I cannot find better solution right now.
Hope one day, there's ip lib from kubernetest just like url.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, this is just kind of the nature of CEL for more complex logic.
/retest |
@@ -122,6 +122,9 @@ type EnvoyProxyKubernetesProvider struct { | |||
// are applied. | |||
// | |||
// +optional | |||
// +kubebuilder:validation:XValidation:message="allocateLoadBalancerNodePorts can only be set for LoadBalancer type",rule="!has(self.allocateLoadBalancerNodePorts) || self.type == 'LoadBalancer'" | |||
// +kubebuilder:validation:XValidation:message="loadBalancerIP can only be set for LoadBalancer type",rule="!has(self.loadBalancerIP) || self.type == 'LoadBalancer'" | |||
// +kubebuilder:validation:XValidation:message="loadBalancerIP must be a valid IPv4 address",rule="!has(self.loadBalancerIP) || self.loadBalancerIP.matches(r\"^(((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.|$)){4})\")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, this is just kind of the nature of CEL for more complex logic.
@@ -3,10 +3,10 @@ | |||
// The full text of the Apache license is available in the LICENSE file at | |||
// the root of the repo. | |||
|
|||
//go:build validation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we rename file to
test/cel/envoyproxy_test.go
and the tag can be celvalidation
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks !
No description provided.