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

CEL validation: implement validateProvider for EnvoyProxy #2081

Merged
merged 6 commits into from
Oct 27, 2023

Conversation

zirain
Copy link
Member

@zirain zirain commented Oct 26, 2023

No description provided.

Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
@zirain zirain requested a review from a team as a code owner October 26, 2023 08:21
@codecov
Copy link

codecov bot commented Oct 26, 2023

Codecov Report

Merging #2081 (7f80353) into main (54803c1) will decrease coverage by 0.08%.
The diff coverage is n/a.

❗ Current head 7f80353 differs from pull request most recent head 0e38d66. Consider uploading reports for the commit 0e38d66 to get more accurate results

@@            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     
Files Coverage Δ
api/v1alpha1/validation/envoyproxy_validate.go 76.28% <ø> (ø)

... and 4 files with indirect coverage changes

tools/make/kube.mk Outdated Show resolved Hide resolved
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})\")"
Copy link
Member Author

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.

Copy link
Member

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.

@zirain
Copy link
Member Author

zirain commented Oct 26, 2023

/retest

Alice-Lilith
Alice-Lilith previously approved these changes Oct 27, 2023
@@ -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})\")"
Copy link
Member

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
Copy link
Contributor

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

tools/make/kube.mk Outdated Show resolved Hide resolved
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Copy link
Contributor

@arkodg arkodg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks !

@arkodg arkodg merged commit 131178b into envoyproxy:main Oct 27, 2023
18 checks passed
@zirain zirain deleted the cel-validation2 branch October 27, 2023 05:00
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

Successfully merging this pull request may close these issues.

3 participants