Skip to content

CEL validation: implement validateProvider for EnvoyProxy#2081

Merged
arkodg merged 6 commits intoenvoyproxy:mainfrom
zirain:cel-validation2
Oct 27, 2023
Merged

CEL validation: implement validateProvider for EnvoyProxy#2081
arkodg merged 6 commits intoenvoyproxy:mainfrom
zirain:cel-validation2

Conversation

@zirain
Copy link
Copy Markdown
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
Copy Markdown

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

Signed-off-by: zirain <zirain2009@gmail.com>
// +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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

zirain commented Oct 26, 2023

/retest

Alice-Lilith
Alice-Lilith previously approved these changes Oct 27, 2023
// +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
Copy Markdown
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.

// The full text of the Apache license is available in the LICENSE file at
// the root of the repo.

//go:build validation
Copy link
Copy Markdown
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

Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Copy link
Copy Markdown
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
@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