Skip to content

Commit

Permalink
Add section name to each route
Browse files Browse the repository at this point in the history
  • Loading branch information
howardjohn committed Apr 17, 2024
1 parent bbbb51b commit 95fe2e1
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apis/v1/grpcroute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,19 @@ type GRPCRouteSpec struct {
//
// +optional
// +kubebuilder:validation:MaxItems=16
// +kubebuilder:validation:XValidation:message="Route name must be unique within the route",rule="self.filter(k,has(k.name)).map(l1,self.filter(k,has(k.name)).exists_one(l2,l1.name == l2.name))"
Rules []GRPCRouteRule `json:"rules,omitempty"`
}

// GRPCRouteRule defines the semantics for matching a gRPC request based on
// conditions (matches), processing it (filters), and forwarding the request to
// an API object (backendRefs).
type GRPCRouteRule struct {
// Name is the name of the route rule. This name MUST be unique within a Route if it is set.
//
// Support: Extended
Name SectionName `json:"name,omitempty"`

// Matches define conditions used for matching the rule against incoming
// gRPC requests. Each match is independent, i.e. this rule will be matched
// if **any** one of the matches is satisfied.
Expand Down
6 changes: 6 additions & 0 deletions apis/v1/httproute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ type HTTPRouteSpec struct {
// Rules are a list of HTTP matchers, filters and actions.
//
// +optional
// +kubebuilder:validation:XValidation:message="Route name must be unique within the route",rule="self.filter(k,has(k.name)).map(l1,self.filter(k,has(k.name)).exists_one(l2,l1.name == l2.name))"
// +kubebuilder:validation:MaxItems=16
// +kubebuilder:default={{matches: {{path: {type: "PathPrefix", value: "/"}}}}}
Rules []HTTPRouteRule `json:"rules,omitempty"`
Expand All @@ -132,6 +133,11 @@ type HTTPRouteSpec struct {
// +kubebuilder:validation:XValidation:message="Within backendRefs, when using RequestRedirect filter with path.replacePrefixMatch, exactly one PathPrefix match must be specified",rule="(has(self.backendRefs) && self.backendRefs.exists_one(b, (has(b.filters) && b.filters.exists_one(f, has(f.requestRedirect) && has(f.requestRedirect.path) && f.requestRedirect.path.type == 'ReplacePrefixMatch' && has(f.requestRedirect.path.replacePrefixMatch))) )) ? ((size(self.matches) != 1 || !has(self.matches[0].path) || self.matches[0].path.type != 'PathPrefix') ? false : true) : true"
// +kubebuilder:validation:XValidation:message="Within backendRefs, When using URLRewrite filter with path.replacePrefixMatch, exactly one PathPrefix match must be specified",rule="(has(self.backendRefs) && self.backendRefs.exists_one(b, (has(b.filters) && b.filters.exists_one(f, has(f.urlRewrite) && has(f.urlRewrite.path) && f.urlRewrite.path.type == 'ReplacePrefixMatch' && has(f.urlRewrite.path.replacePrefixMatch))) )) ? ((size(self.matches) != 1 || !has(self.matches[0].path) || self.matches[0].path.type != 'PathPrefix') ? false : true) : true"
type HTTPRouteRule struct {
// Name is the name of the route rule. This name MUST be unique within a Route if it is set.
//
// Support: Extended
Name SectionName `json:"name,omitempty"`

// Matches define conditions used for matching the rule against incoming
// HTTP requests. Each match is independent, i.e. this rule will be matched
// if **any** one of the matches is satisfied.
Expand Down
6 changes: 6 additions & 0 deletions apis/v1alpha2/tcproute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type TCPRouteSpec struct {
//
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=16
// +kubebuilder:validation:XValidation:message="Route name must be unique within the route",rule="self.filter(k,has(k.name)).map(l1,self.filter(k,has(k.name)).exists_one(l2,l1.name == l2.name))"
Rules []TCPRouteRule `json:"rules"`
}

Expand All @@ -59,6 +60,11 @@ type TCPRouteStatus struct {

// TCPRouteRule is the configuration for a given rule.
type TCPRouteRule struct {
// Name is the name of the route rule. This name MUST be unique within a Route if it is set.
//
// Support: Extended
Name SectionName `json:"name,omitempty"`

// BackendRefs defines the backend(s) where matching requests should be
// sent. If unspecified or invalid (refers to a non-existent resource or a
// Service with no endpoints), the underlying implementation MUST actively
Expand Down
6 changes: 6 additions & 0 deletions apis/v1alpha2/tlsroute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ type TLSRouteSpec struct {
//
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=16
// +kubebuilder:validation:XValidation:message="Route name must be unique within the route",rule="self.filter(k,has(k.name)).map(l1,self.filter(k,has(k.name)).exists_one(l2,l1.name == l2.name))"
Rules []TLSRouteRule `json:"rules"`
}

Expand All @@ -100,6 +101,11 @@ type TLSRouteStatus struct {

// TLSRouteRule is the configuration for a given rule.
type TLSRouteRule struct {
// Name is the name of the route rule. This name MUST be unique within a Route if it is set.
//
// Support: Extended
Name SectionName `json:"name,omitempty"`

// BackendRefs defines the backend(s) where matching requests should be
// sent. If unspecified or invalid (refers to a non-existent resource or
// a Service with no endpoints), the rule performs no forwarding; if no
Expand Down
6 changes: 6 additions & 0 deletions apis/v1alpha2/udproute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type UDPRouteSpec struct {
//
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=16
// +kubebuilder:validation:XValidation:message="Route name must be unique within the route",rule="self.filter(k,has(k.name)).map(l1,self.filter(k,has(k.name)).exists_one(l2,l1.name == l2.name))"
Rules []UDPRouteRule `json:"rules"`
}

Expand All @@ -59,6 +60,11 @@ type UDPRouteStatus struct {

// UDPRouteRule is the configuration for a given rule.
type UDPRouteRule struct {
// Name is the name of the route rule. This name MUST be unique within a Route if it is set.
//
// Support: Extended
Name SectionName `json:"name,omitempty"`

// BackendRefs defines the backend(s) where matching requests should be
// sent. If unspecified or invalid (refers to a non-existent resource or a
// Service with no endpoints), the underlying implementation MUST actively
Expand Down

0 comments on commit 95fe2e1

Please sign in to comment.