Skip to content

Commit

Permalink
fix: Remove ErrHTTPRouteMatchEmpty check for Xds IR (envoyproxy#1959)
Browse files Browse the repository at this point in the history
  • Loading branch information
arkodg authored Oct 13, 2023
1 parent 57b00ed commit 3827919
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 28 deletions.
4 changes: 0 additions & 4 deletions internal/ir/xds.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ var (
ErrTLSPrivateKey = errors.New("field PrivateKey must be specified")
ErrHTTPRouteNameEmpty = errors.New("field Name must be specified")
ErrHTTPRouteHostnameEmpty = errors.New("field Hostname must be specified")
ErrHTTPRouteMatchEmpty = errors.New("either PathMatch, HeaderMatches or QueryParamMatches fields must be specified")
ErrDestinationNameEmpty = errors.New("field Name must be specified")
ErrDestEndpointHostInvalid = errors.New("field Address must be a valid IP address")
ErrDestEndpointPortInvalid = errors.New("field Port specified is invalid")
Expand Down Expand Up @@ -317,9 +316,6 @@ func (h HTTPRoute) Validate() error {
if h.Hostname == "" {
errs = multierror.Append(errs, ErrHTTPRouteHostnameEmpty)
}
if h.PathMatch == nil && (len(h.HeaderMatches) == 0) && (len(h.QueryParamMatches) == 0) {
errs = multierror.Append(errs, ErrHTTPRouteMatchEmpty)
}
if h.PathMatch != nil {
if err := h.PathMatch.Validate(); err != nil {
errs = multierror.Append(errs, err)
Expand Down
26 changes: 2 additions & 24 deletions internal/ir/xds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ var (
Hostnames: []string{"example.com"},
Routes: []*HTTPRoute{&happyHTTPRoute},
}
invalidRouteMatchHTTPListener = HTTPListener{
Name: "invalid-route-match",
Address: "0.0.0.0",
Port: 80,
Hostnames: []string{"example.com"},
Routes: []*HTTPRoute{&emptyMatchHTTPRoute},
}
invalidBackendHTTPListener = HTTPListener{
Name: "invalid-backend-match",
Address: "0.0.0.0",
Expand Down Expand Up @@ -146,11 +139,6 @@ var (
},
Destination: &happyRouteDestination,
}
emptyMatchHTTPRoute = HTTPRoute{
Name: "empty-match",
Hostname: "*",
Destination: &happyRouteDestination,
}
invalidBackendHTTPRoute = HTTPRoute{
Name: "invalid-backend",
Hostname: "*",
Expand Down Expand Up @@ -510,9 +498,9 @@ func TestValidateXds(t *testing.T) {
{
name: "invalid listener",
input: Xds{
HTTP: []*HTTPListener{&happyHTTPListener, &invalidAddrHTTPListener, &invalidRouteMatchHTTPListener},
HTTP: []*HTTPListener{&happyHTTPListener, &invalidAddrHTTPListener},
},
want: []error{ErrListenerAddressInvalid, ErrHTTPRouteMatchEmpty},
want: []error{ErrListenerAddressInvalid},
},
{
name: "invalid backend",
Expand Down Expand Up @@ -579,11 +567,6 @@ func TestValidateHTTPListener(t *testing.T) {
},
want: []error{ErrListenerPortInvalid, ErrHTTPListenerHostnamesEmpty},
},
{
name: "invalid route match",
input: invalidRouteMatchHTTPListener,
want: []error{ErrHTTPRouteMatchEmpty},
},
}
for _, test := range tests {
test := test
Expand Down Expand Up @@ -837,11 +820,6 @@ func TestValidateHTTPRoute(t *testing.T) {
},
want: []error{ErrHTTPRouteHostnameEmpty},
},
{
name: "empty match",
input: emptyMatchHTTPRoute,
want: []error{ErrHTTPRouteMatchEmpty},
},
{
name: "invalid backend",
input: invalidBackendHTTPRoute,
Expand Down

0 comments on commit 3827919

Please sign in to comment.