-
Notifications
You must be signed in to change notification settings - Fork 468
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
Add shared type HeaderName
and use it for GRPCHeaderName
, HTTPHeaderName
and QueryParamMatchName
#1796
Add shared type HeaderName
and use it for GRPCHeaderName
, HTTPHeaderName
and QueryParamMatchName
#1796
Conversation
@shaneutt Can you review it? Thanks. |
apis/v1beta1/httproute_types.go
Outdated
@@ -452,6 +452,7 @@ type HTTPQueryParamMatch struct { | |||
// | |||
// +kubebuilder:validation:MinLength=1 | |||
// +kubebuilder:validation:MaxLength=256 | |||
// +kubebuilder:validation:Pattern=`^[A-Za-z0-9!#$%&'*+\-.^_\x60|~]+$` |
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.
Was this pattern specifically pulled from a reference somewhere?
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.
Yes, I pulled this pattern from other names properties likes:
https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1alpha2/httproute_types.go#L117
https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1beta1/httproute_types.go#L350
https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1alpha2/grpcroute_types.go#L414
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 use HTTPHeaderName
as the type here instead of copying the regex? Would make this easier to maintain going forward.
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.
Thanks @gyohuangxin! One tiny nit but otherwise LGTM.
apis/v1beta1/httproute_types.go
Outdated
@@ -452,6 +452,7 @@ type HTTPQueryParamMatch struct { | |||
// | |||
// +kubebuilder:validation:MinLength=1 | |||
// +kubebuilder:validation:MaxLength=256 | |||
// +kubebuilder:validation:Pattern=`^[A-Za-z0-9!#$%&'*+\-.^_\x60|~]+$` |
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 use HTTPHeaderName
as the type here instead of copying the regex? Would make this easier to maintain going forward.
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.
generally seems right, but agree with @robscott's idea to not have to repeat the same regex pattern many places, i don't know if adding another layer of type aliasing would be what we want to do/even work as we intend but that might be an idea to explore (e.g GRPCHeaderName
, HTTPHeaderName
and query param match name
all use the same underlying more neutrally-named type)
Thanks for your comments. Agreed with @sunjayBhatia , the better solution is to introduce a shared type like |
Yep sgtm, setting to draft to sort that out so this doesn't accidentally get merged 👍 |
Signed-off-by: Huang Xin <xin1.huang@intel.com>
…ame and QueryParamMatchName Signed-off-by: Xin Huang <xin1.huang@intel.com>
abafab3
to
d1202af
Compare
HeaderName
and use it for GRPCHeaderName
, HTTPHeaderName
and QueryParamMatchName
Signed-off-by: Huang Xin <xin1.huang@intel.com>
@robscott Could you review this? Thanks |
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.
Rob approved previously just with the caveat of the common type, we're all set thank you @gyohuangxin!!! 🥳
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gyohuangxin, shaneutt, sunjayBhatia The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind bug
What this PR does / why we need it:
Add pattern for query param name in HTTPQueryParamMatch like other items' names to avoid illegal names.
Which issue(s) this PR fixes:
Fixes #1729
Does this PR introduce a user-facing change?: