diff --git a/apis/v1alpha2/shared_types.go b/apis/v1alpha2/shared_types.go index 5bc7e5a439..37de51000b 100644 --- a/apis/v1alpha2/shared_types.go +++ b/apis/v1alpha2/shared_types.go @@ -384,9 +384,9 @@ type AnnotationKey string // +kubebuilder:validation:MaxLength=4096 type AnnotationValue string -// TrafficMatches defines AddressMatch rules for inbound traffic according to +// AddressRouteMatches defines AddressMatch rules for inbound traffic according to // source and/or destination address of a packet or connection. -type TrafficMatches struct { +type AddressRouteMatches struct { // SourceAddresses indicates the originating (source) network // addresses which are valid for routing traffic. // diff --git a/apis/v1alpha2/tcproute_types.go b/apis/v1alpha2/tcproute_types.go index 6a666805d0..c8ea05bb4b 100644 --- a/apis/v1alpha2/tcproute_types.go +++ b/apis/v1alpha2/tcproute_types.go @@ -62,7 +62,7 @@ type TCPRouteRule struct { // Matches are rules for routing traffic to backends based on addresses. // // +optional - Matches *TrafficMatches `json:"matches,omitempty"` + Matches *AddressRouteMatches `json:"matches,omitempty"` // BackendRefs defines the backend(s) where matching requests should be // sent. If unspecified or invalid (refers to a non-existent resource or a diff --git a/apis/v1alpha2/udproute_types.go b/apis/v1alpha2/udproute_types.go index 9fd8f4e6f0..fcf90e47a3 100644 --- a/apis/v1alpha2/udproute_types.go +++ b/apis/v1alpha2/udproute_types.go @@ -62,7 +62,7 @@ type UDPRouteRule struct { // Matches add rules for filtering traffic to backends based on addresses. // // +optional - Matches *TrafficMatches `json:"matches,omitempty"` + Matches *AddressRouteMatches `json:"matches,omitempty"` // BackendRefs defines the backend(s) where matching requests should be // sent. If unspecified or invalid (refers to a non-existent resource or a diff --git a/apis/v1alpha2/zz_generated.deepcopy.go b/apis/v1alpha2/zz_generated.deepcopy.go index 2ce87444b2..59f1c130c0 100644 --- a/apis/v1alpha2/zz_generated.deepcopy.go +++ b/apis/v1alpha2/zz_generated.deepcopy.go @@ -46,6 +46,35 @@ func (in *AddressMatch) DeepCopy() *AddressMatch { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AddressRouteMatches) DeepCopyInto(out *AddressRouteMatches) { + *out = *in + if in.SourceAddresses != nil { + in, out := &in.SourceAddresses, &out.SourceAddresses + *out = make([]AddressMatch, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.DestinationAddresses != nil { + in, out := &in.DestinationAddresses, &out.DestinationAddresses + *out = make([]AddressMatch, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddressRouteMatches. +func (in *AddressRouteMatches) DeepCopy() *AddressRouteMatches { + if in == nil { + return nil + } + out := new(AddressRouteMatches) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AllowedRoutes) DeepCopyInto(out *AllowedRoutes) { *out = *in @@ -1339,7 +1368,7 @@ func (in *TCPRouteRule) DeepCopyInto(out *TCPRouteRule) { *out = *in if in.Matches != nil { in, out := &in.Matches, &out.Matches - *out = new(TrafficMatches) + *out = new(AddressRouteMatches) (*in).DeepCopyInto(*out) } if in.BackendRefs != nil { @@ -1525,35 +1554,6 @@ func (in *TLSRouteStatus) DeepCopy() *TLSRouteStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TrafficMatches) DeepCopyInto(out *TrafficMatches) { - *out = *in - if in.SourceAddresses != nil { - in, out := &in.SourceAddresses, &out.SourceAddresses - *out = make([]AddressMatch, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.DestinationAddresses != nil { - in, out := &in.DestinationAddresses, &out.DestinationAddresses - *out = make([]AddressMatch, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TrafficMatches. -func (in *TrafficMatches) DeepCopy() *TrafficMatches { - if in == nil { - return nil - } - out := new(TrafficMatches) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *UDPRoute) DeepCopyInto(out *UDPRoute) { *out = *in @@ -1618,7 +1618,7 @@ func (in *UDPRouteRule) DeepCopyInto(out *UDPRouteRule) { *out = *in if in.Matches != nil { in, out := &in.Matches, &out.Matches - *out = new(TrafficMatches) + *out = new(AddressRouteMatches) (*in).DeepCopyInto(*out) } if in.BackendRefs != nil { diff --git a/site-src/geps/gep-735.md b/site-src/geps/gep-735.md index 5d19d3cc58..81bb1fa847 100644 --- a/site-src/geps/gep-735.md +++ b/site-src/geps/gep-735.md @@ -32,7 +32,7 @@ level of tuning options for L4 traffic routing at a level below the `Gateway`. The API changes include the following new types: - `AddressMatch` to indicate the IP for address matching -- `TrafficMatches` to configure matching according to network address +- `AddressRouteMatches` to configure matching according to network address These types enable the address matching required, with some active considerations about how to leave these open ended for later expansion. @@ -78,13 +78,13 @@ type AddressMatch struct { } ``` -### TrafficMatches Type +### AddressRouteMatches Type Using the new `AddressMatch` type matches can be expressed in topical lists on -`TCPRoute` and `UDPRoute` using the new `TrafficMatches` type: +`TCPRoute` and `UDPRoute` using the new `AddressRouteMatches` type: ```go -type TrafficMatches struct { +type AddressRouteMatches struct { // SourceAddresses indicates the originating (source) network // addresses which are valid for routing traffic. // @@ -100,17 +100,21 @@ type TrafficMatches struct { ``` This type becomes an optional field and shared by both `TCPRouteRule` and -`UDPRouteRule`: +`UDPRouteRule` as a list: ```go type TCPRouteRule struct { // Matches add rules for filtering traffic to backends based on addresses. // // +optional - Matches *TrafficMatches `json:"matches,omitempty"` + Matches []AddressRouteMatches `json:"matches,omitempty"` } ``` +Each element in `[]AddressRouteMatches` should be implemented as an `OR` style +match (e.g. the inbound traffic matches as long as at least one of the separate +`AddressRouteMatches` rules is matched). + The above would make the following YAML examples possible: ```yaml