Skip to content

Commit 73a77fa

Browse files
committed
Gateway API v0.5.0 API Review
1 parent 36736f7 commit 73a77fa

6 files changed

+240
-56
lines changed

apis/v1alpha2/gateway_types.go

+4-36
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ type GatewaySpec struct {
145145
// Listener embodies the concept of a logical endpoint where a Gateway accepts
146146
// network connections.
147147
type Listener struct {
148-
// Name is the name of the Listener.
148+
// Name is the name of the Listener. This name MUST be unique within a
149+
// Gateway.
149150
//
150151
// Support: Core
151152
Name SectionName `json:"name"`
@@ -381,7 +382,7 @@ type AllowedRoutes struct {
381382
// with the application protocol specified in the Listener's Protocol field.
382383
// If an implementation does not support or recognize this resource type, it
383384
// MUST set the "ResolvedRefs" condition to False for this Listener with the
384-
// "InvalidRoutesRef" reason.
385+
// "InvalidRouteKinds" reason.
385386
//
386387
// Support: Core
387388
//
@@ -449,6 +450,7 @@ type GatewayAddress struct {
449450
// Type of the address.
450451
//
451452
// +optional
453+
// +kubebuilder:validation:Enum=IPAddress;Hostname;NamedAddress
452454
// +kubebuilder:default=IPAddress
453455
Type *AddressType `json:"type,omitempty"`
454456

@@ -462,40 +464,6 @@ type GatewayAddress struct {
462464
Value string `json:"value"`
463465
}
464466

465-
// AddressType defines how a network address is represented as a text string.
466-
//
467-
// If the requested address is unsupported, the controller
468-
// should raise the "Detached" listener status condition on
469-
// the Gateway with the "UnsupportedAddress" reason.
470-
//
471-
// +kubebuilder:validation:Enum=IPAddress;Hostname;NamedAddress
472-
type AddressType string
473-
474-
const (
475-
// A textual representation of a numeric IP address. IPv4
476-
// addresses must be in dotted-decimal form. IPv6 addresses
477-
// must be in a standard IPv6 text representation
478-
// (see [RFC 5952](https://tools.ietf.org/html/rfc5952)).
479-
//
480-
// Support: Extended
481-
IPAddressType AddressType = "IPAddress"
482-
483-
// A Hostname represents a DNS based ingress point. This is similar to the
484-
// corresponding hostname field in Kubernetes load balancer status. For
485-
// example, this concept may be used for cloud load balancers where a DNS
486-
// name is used to expose a load balancer.
487-
//
488-
// Support: Extended
489-
HostnameAddressType AddressType = "Hostname"
490-
491-
// A NamedAddress provides a way to reference a specific IP address by name.
492-
// For example, this may be a name or other unique identifier that refers
493-
// to a resource on a cloud provider such as a static IP.
494-
//
495-
// Support: Implementation-Specific
496-
NamedAddressType AddressType = "NamedAddress"
497-
)
498-
499467
// GatewayStatus defines the observed state of Gateway.
500468
type GatewayStatus struct {
501469
// Addresses lists the IP addresses that have actually been

apis/v1alpha2/httproute_types.go

+99-9
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ type HTTPRouteRule struct {
152152
//
153153
// * The oldest Route based on creation timestamp.
154154
// * The Route appearing first in alphabetical order by
155-
// "<namespace>/<name>".
155+
// "{namespace}/{name}".
156156
//
157157
// If ties still exist within the Route that has been given precedence,
158158
// matching precedence MUST be granted to the first matching rule meeting
@@ -227,11 +227,10 @@ const (
227227
// Matches based on a URL path prefix split by `/`. Matching is
228228
// case sensitive and done on a path element by element basis. A
229229
// path element refers to the list of labels in the path split by
230-
// the `/` separator. A request is a match for path _p_ if every
231-
// _p_ is an element-wise prefix of the request path.
230+
// the `/` separator. When specified, a trailing `/` is ignored.
232231
//
233-
// For example, `/abc`, `/abc/` and `/abc/def` match the prefix
234-
// `/abc`, but `/abcd` does not.
232+
// For example. the paths `/abc`, `/abc/`, and `/abc/def` would all match
233+
// the prefix `/abc`, but the path `/abcd` would not.
235234
//
236235
// "PathPrefix" is semantically equivalent to the "Prefix" path type in the
237236
// Kubernetes Ingress API.
@@ -495,6 +494,8 @@ type HTTPRouteFilter struct {
495494
// that filter MUST receive a HTTP error response.
496495
//
497496
// +unionDiscriminator
497+
// +kubebuilder:validation:Enum=RequestHeaderModifier;RequestMirror;RequestRedirect;ExtensionRef
498+
// <gateway:experimental:validation:Enum=RequestHeaderModifier;RequestMirror;RequestRedirect;URLRewrite;ExtensionRef>
498499
Type HTTPRouteFilterType `json:"type"`
499500

500501
// RequestHeaderModifier defines a schema for a filter that modifies request
@@ -522,6 +523,13 @@ type HTTPRouteFilter struct {
522523
// +optional
523524
RequestRedirect *HTTPRequestRedirectFilter `json:"requestRedirect,omitempty"`
524525

526+
// URLRewrite defines a schema for a filter that modifies a request during forwarding.
527+
// Support: Extended
528+
//
529+
// <gateway:experimental>
530+
// +optional
531+
URLRewrite *HTTPURLRewriteFilter `json:"urlRewrite,omitempty"`
532+
525533
// ExtensionRef is an optional, implementation-specific extension to the
526534
// "filter" behavior. For example, resource "myroutefilter" in group
527535
// "networking.example.net"). ExtensionRef MUST NOT be used for core and
@@ -534,7 +542,6 @@ type HTTPRouteFilter struct {
534542
}
535543

536544
// HTTPRouteFilterType identifies a type of HTTPRoute filter.
537-
// +kubebuilder:validation:Enum=RequestHeaderModifier;RequestMirror;RequestRedirect;ExtensionRef
538545
type HTTPRouteFilterType string
539546

540547
const (
@@ -548,13 +555,26 @@ const (
548555

549556
// HTTPRouteFilterRequestRedirect can be used to redirect a request to
550557
// another location. This filter can also be used for HTTP to HTTPS
551-
// redirects.
558+
// redirects. This may not be used on the same Route rule or BackendRef as a
559+
// URLRewrite filter.
552560
//
553561
// Support in HTTPRouteRule: Core
554562
//
555563
// Support in HTTPBackendRef: Extended
556564
HTTPRouteFilterRequestRedirect HTTPRouteFilterType = "RequestRedirect"
557565

566+
// HTTPRouteFilterURLRewrite can be used to modify a request during
567+
// forwarding. At most one of these filters may be used on a Route rule.
568+
// This may not be used on the same Route rule or BackendRef as a
569+
// RequestRedirect filter.
570+
//
571+
// Support in HTTPRouteRule: Extended
572+
//
573+
// Support in HTTPBackendRef: Extended
574+
//
575+
// <gateway:experimental>
576+
HTTPRouteFilterURLRewrite HTTPRouteFilterType = "URLRewrite"
577+
558578
// HTTPRouteFilterRequestMirror can be used to mirror HTTP requests to a
559579
// different backend. The responses from this backend MUST be ignored by
560580
// the Gateway.
@@ -664,7 +684,42 @@ type HTTPRequestHeaderFilter struct {
664684
Remove []string `json:"remove,omitempty"`
665685
}
666686

667-
// HTTPRequestRedirectFilter defines configuration for the RequestRedirect filter.
687+
// HTTPPathModifierType defines the type of path redirect.
688+
type HTTPPathModifierType string
689+
690+
const (
691+
// This type of modifier indicates that the complete path will be replaced
692+
// by the path redirect value.
693+
AbsoluteHTTPPathModifier HTTPPathModifierType = "Absolute"
694+
695+
// This type of modifier indicates that any prefix path matches will be
696+
// replaced by the substitution value. For example, a path with a prefix
697+
// match of "/foo" and a ReplacePrefixMatch substitution of "/bar" will have
698+
// the "/foo" prefix replaced with "/bar" in matching requests.
699+
PrefixMatchHTTPPathModifier HTTPPathModifierType = "ReplacePrefixMatch"
700+
)
701+
702+
// HTTPPathModifier defines configuration for path modifiers.
703+
// <gateway:experimental>
704+
type HTTPPathModifier struct {
705+
// Type defines the type of path modifier.
706+
//
707+
// <gateway:experimental>
708+
// +kubebuilder:validation:Enum=Absolute;ReplacePrefixMatch
709+
Type HTTPPathModifierType `json:"type"`
710+
711+
// Substitution defines the HTTP path value to substitute. An empty value
712+
// ("") indicates that the portion of the path to be changed should be
713+
// removed from the resulting path. For example, a request to "/foo/bar"
714+
// with a prefix match of "/foo" would be modified to "/bar".
715+
//
716+
// <gateway:experimental>
717+
// +kubebuilder:validation:MaxLength=1024
718+
Substitution string `json:"substitution"`
719+
}
720+
721+
// HTTPRequestRedirect defines a filter that redirects a request. This filter
722+
// MUST not be used on the same Route rule as a HTTPURLRewrite filter.
668723
type HTTPRequestRedirectFilter struct {
669724
// Scheme is the scheme to be used in the value of the `Location`
670725
// header in the response.
@@ -685,6 +740,16 @@ type HTTPRequestRedirectFilter struct {
685740
// +optional
686741
Hostname *PreciseHostname `json:"hostname,omitempty"`
687742

743+
// Path defines parameters used to modify the path of the incoming request.
744+
// The modified path is then used to construct the `Location` header. When
745+
// empty, the request path is used as-is.
746+
//
747+
// Support: Extended
748+
//
749+
// <gateway:experimental>
750+
// +optional
751+
Path *HTTPPathModifier `json:"path,omitempty"`
752+
688753
// Port is the port to be used in the value of the `Location`
689754
// header in the response.
690755
// When empty, port (if specified) of the request is used.
@@ -704,6 +769,31 @@ type HTTPRequestRedirectFilter struct {
704769
StatusCode *int `json:"statusCode,omitempty"`
705770
}
706771

772+
// HTTPURLRewriteFilter defines a filter that modifies a request during
773+
// forwarding. At most one of these filters may be used on a Route rule. This
774+
// may not be used on the same Route rule as a HTTPRequestRedirect filter.
775+
//
776+
// <gateway:experimental>
777+
// Support: Extended
778+
type HTTPURLRewriteFilter struct {
779+
// Hostname is the value to be used to replace the Host header value during
780+
// forwarding.
781+
//
782+
// Support: Extended
783+
//
784+
// <gateway:experimental>
785+
// +optional
786+
Hostname *Hostname `json:"hostname,omitempty"`
787+
788+
// Path defines a path rewrite.
789+
//
790+
// Support: Extended
791+
//
792+
// <gateway:experimental>
793+
// +optional
794+
Path *HTTPPathModifier `json:"path,omitempty"`
795+
}
796+
707797
// HTTPRequestMirrorFilter defines configuration for the RequestMirror filter.
708798
type HTTPRequestMirrorFilter struct {
709799
// BackendRef references a resource where mirrored requests are sent.
@@ -738,7 +828,7 @@ type HTTPBackendRef struct {
738828
//
739829
// If there is a cross-namespace reference to an *existing* object
740830
// that is not covered by a ReferencePolicy, the controller must ensure the
741-
// "ResolvedRefs" condition on the Route is set to `status: true`,
831+
// "ResolvedRefs" condition on the Route is set to `status: False`,
742832
// with the "RefNotPermitted" reason and not configure this backend in the
743833
// underlying implementation.
744834
//

apis/v1alpha2/referencepolicy_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ type ReferencePolicyTo struct {
123123
// * Service
124124
Kind Kind `json:"kind"`
125125

126-
// Name is the name of the referent. When unspecified or empty, this policy
126+
// Name is the name of the referent. When unspecified, this policy
127127
// refers to all resources of the specified Group and Kind in the local
128128
// namespace.
129129
//

0 commit comments

Comments
 (0)