Skip to content

Commit 5e8421c

Browse files
authored
Merge pull request #1258 from youngnick/enum-details-update
Enum details update
2 parents 9a3de63 + e5340d6 commit 5e8421c

File tree

7 files changed

+357
-36
lines changed

7 files changed

+357
-36
lines changed

apis/v1alpha2/gateway_types.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,13 @@ type GatewayTLSConfig struct {
351351

352352
// TLSModeType type defines how a Gateway handles TLS sessions.
353353
//
354+
// Note that values may be added to this enum, implementations
355+
// must ensure that unknown values will not cause a crash.
356+
//
357+
// Unknown values here must result in the implementation setting the
358+
// Ready Condition for the Listener to `status: False`, with a
359+
// Reason of `Invalid`.
360+
//
354361
// +kubebuilder:validation:Enum=Terminate;Passthrough
355362
type TLSModeType string
356363

@@ -398,6 +405,13 @@ type AllowedRoutes struct {
398405
// FromNamespaces specifies namespace from which Routes may be attached to a
399406
// Gateway.
400407
//
408+
// Note that values may be added to this enum, implementations
409+
// must ensure that unknown values will not cause a crash.
410+
//
411+
// Unknown values here must result in the implementation setting the
412+
// Ready Condition for the Listener to `status: False`, with a
413+
// Reason of `Invalid`.
414+
//
401415
// +kubebuilder:validation:Enum=All;Selector;Same
402416
type FromNamespaces string
403417

apis/v1alpha2/httproute_types.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,13 @@ type HTTPRouteRule struct {
244244
// - Must begin with the `/` character
245245
// - Must not contain consecutive `/` characters (e.g. `/foo///`, `//`).
246246
//
247+
// Note that values may be added to this enum, implementations
248+
// must ensure that unknown values will not cause a crash.
249+
//
250+
// Unknown values here must result in the implementation setting the
251+
// Attached Condition for the Route to `status: False`, with a
252+
// Reason of `UnsupportedValue`.
253+
//
247254
// +kubebuilder:validation:Enum=Exact;PathPrefix;RegularExpression
248255
type PathMatchType string
249256

@@ -299,6 +306,13 @@ type HTTPPathMatch struct {
299306
// * "Exact"
300307
// * "RegularExpression"
301308
//
309+
// Note that values may be added to this enum, implementations
310+
// must ensure that unknown values will not cause a crash.
311+
//
312+
// Unknown values here must result in the implementation setting the
313+
// Attached Condition for the Route to `status: False`, with a
314+
// Reason of `UnsupportedValue`.
315+
//
302316
// +kubebuilder:validation:Enum=Exact;RegularExpression
303317
type HeaderMatchType string
304318

@@ -373,6 +387,13 @@ type HTTPHeaderMatch struct {
373387
// * "Exact"
374388
// * "RegularExpression"
375389
//
390+
// Note that values may be added to this enum, implementations
391+
// must ensure that unknown values will not cause a crash.
392+
//
393+
// Unknown values here must result in the implementation setting the
394+
// Attached Condition for the Route to `status: False`, with a
395+
// Reason of `UnsupportedValue`.
396+
//
376397
// +kubebuilder:validation:Enum=Exact;RegularExpression
377398
type QueryParamMatchType string
378399

@@ -424,6 +445,14 @@ type HTTPQueryParamMatch struct {
424445
// [RFC 7231](https://datatracker.ietf.org/doc/html/rfc7231#section-4) and
425446
// [RFC 5789](https://datatracker.ietf.org/doc/html/rfc5789#section-2).
426447
// The value is expected in upper case.
448+
//
449+
// Note that values may be added to this enum, implementations
450+
// must ensure that unknown values will not cause a crash.
451+
//
452+
// Unknown values here must result in the implementation setting the
453+
// Attached Condition for the Route to `status: False`, with a
454+
// Reason of `UnsupportedValue`.
455+
//
427456
// +kubebuilder:validation:Enum=GET;HEAD;POST;PUT;DELETE;CONNECT;OPTIONS;TRACE;PATCH
428457
type HTTPMethod string
429458

@@ -524,6 +553,13 @@ type HTTPRouteFilter struct {
524553
// MUST NOT be skipped. Instead, requests that would have been processed by
525554
// that filter MUST receive a HTTP error response.
526555
//
556+
// Note that values may be added to this enum, implementations
557+
// must ensure that unknown values will not cause a crash.
558+
//
559+
// Unknown values here must result in the implementation setting the
560+
// Attached Condition for the Route to `status: False`, with a
561+
// Reason of `UnsupportedValue`.
562+
//
527563
// +unionDiscriminator
528564
// +kubebuilder:validation:Enum=RequestHeaderModifier;RequestMirror;RequestRedirect;ExtensionRef
529565
// <gateway:experimental:validation:Enum=RequestHeaderModifier;RequestMirror;RequestRedirect;URLRewrite;ExtensionRef>
@@ -743,6 +779,13 @@ type HTTPPathModifier struct {
743779
// Type defines the type of path modifier. Additional types may be
744780
// added in a future release of the API.
745781
//
782+
// Note that values may be added to this enum, implementations
783+
// must ensure that unknown values will not cause a crash.
784+
//
785+
// Unknown values here must result in the implementation setting the
786+
// Attached Condition for the Route to `status: False`, with a
787+
// Reason of `UnsupportedValue`.
788+
//
746789
// <gateway:experimental>
747790
// +kubebuilder:validation:Enum=ReplaceFullPath;ReplacePrefixMatch
748791
Type HTTPPathModifierType `json:"type"`
@@ -780,6 +823,13 @@ type HTTPRequestRedirectFilter struct {
780823
//
781824
// Support: Extended
782825
//
826+
// Note that values may be added to this enum, implementations
827+
// must ensure that unknown values will not cause a crash.
828+
//
829+
// Unknown values here must result in the implementation setting the
830+
// Attached Condition for the Route to `status: False`, with a
831+
// Reason of `UnsupportedValue`.
832+
//
783833
// +optional
784834
// +kubebuilder:validation:Enum=http;https
785835
Scheme *string `json:"scheme,omitempty"`
@@ -816,6 +866,13 @@ type HTTPRequestRedirectFilter struct {
816866
//
817867
// Support: Core
818868
//
869+
// Note that values may be added to this enum, implementations
870+
// must ensure that unknown values will not cause a crash.
871+
//
872+
// Unknown values here must result in the implementation setting the
873+
// Attached Condition for the Route to `status: False`, with a
874+
// Reason of `UnsupportedValue`.
875+
//
819876
// +optional
820877
// +kubebuilder:default=302
821878
// +kubebuilder:validation:Enum=301;302

apis/v1alpha2/shared_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ const (
217217
// compatible Listeners whose Hostname matches the route
218218
RouteReasonNoMatchingListenerHostname RouteConditionReason = "NoMatchingListenerHostname"
219219

220+
// This reason is used with the "Accepted" condition when a value for an Enum
221+
// is not recognized.
222+
RouteReasonUnsupportedValue RouteConditionReason = "UnsupportedValue"
223+
220224
// This condition indicates whether the controller was able to resolve all
221225
// the object references for the Route.
222226
//

apis/v1beta1/httproute_types.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ type HTTPRouteRule struct {
221221
// recommended to return a 503 status code.
222222
//
223223
// Support: Core for Kubernetes Service
224+
//
224225
// Support: Custom for any other resource
225226
//
226227
// Support for weight: Core
@@ -242,6 +243,13 @@ type HTTPRouteRule struct {
242243
// - Must begin with the `/` character
243244
// - Must not contain consecutive `/` characters (e.g. `/foo///`, `//`).
244245
//
246+
// Note that values may be added to this enum, implementations
247+
// must ensure that unknown values will not cause a crash.
248+
//
249+
// Unknown values here must result in the implementation setting the
250+
// Attached Condition for the Route to `status: False`, with a
251+
// Reason of `UnsupportedValue`.
252+
//
245253
// +kubebuilder:validation:Enum=Exact;PathPrefix;RegularExpression
246254
type PathMatchType string
247255

@@ -297,6 +305,13 @@ type HTTPPathMatch struct {
297305
// * "Exact"
298306
// * "RegularExpression"
299307
//
308+
// Note that values may be added to this enum, implementations
309+
// must ensure that unknown values will not cause a crash.
310+
//
311+
// Unknown values here must result in the implementation setting the
312+
// Attached Condition for the Route to `status: False`, with a
313+
// Reason of `UnsupportedValue`.
314+
//
300315
// +kubebuilder:validation:Enum=Exact;RegularExpression
301316
type HeaderMatchType string
302317

@@ -371,6 +386,13 @@ type HTTPHeaderMatch struct {
371386
// * "Exact"
372387
// * "RegularExpression"
373388
//
389+
// Note that values may be added to this enum, implementations
390+
// must ensure that unknown values will not cause a crash.
391+
//
392+
// Unknown values here must result in the implementation setting the
393+
// Attached Condition for the Route to `status: False`, with a
394+
// Reason of `UnsupportedValue`.
395+
//
374396
// +kubebuilder:validation:Enum=Exact;RegularExpression
375397
type QueryParamMatchType string
376398

@@ -422,6 +444,14 @@ type HTTPQueryParamMatch struct {
422444
// [RFC 7231](https://datatracker.ietf.org/doc/html/rfc7231#section-4) and
423445
// [RFC 5789](https://datatracker.ietf.org/doc/html/rfc5789#section-2).
424446
// The value is expected in upper case.
447+
//
448+
// Note that values may be added to this enum, implementations
449+
// must ensure that unknown values will not cause a crash.
450+
//
451+
// Unknown values here must result in the implementation setting the
452+
// Attached Condition for the Route to `status: False`, with a
453+
// Reason of `UnsupportedValue`.
454+
//
425455
// +kubebuilder:validation:Enum=GET;HEAD;POST;PUT;DELETE;CONNECT;OPTIONS;TRACE;PATCH
426456
type HTTPMethod string
427457

@@ -522,6 +552,13 @@ type HTTPRouteFilter struct {
522552
// MUST NOT be skipped. Instead, requests that would have been processed by
523553
// that filter MUST receive a HTTP error response.
524554
//
555+
// Note that values may be added to this enum, implementations
556+
// must ensure that unknown values will not cause a crash.
557+
//
558+
// Unknown values here must result in the implementation setting the
559+
// Attached Condition for the Route to `status: False`, with a
560+
// Reason of `UnsupportedValue`.
561+
//
525562
// +unionDiscriminator
526563
// +kubebuilder:validation:Enum=RequestHeaderModifier;RequestMirror;RequestRedirect;ExtensionRef
527564
// <gateway:experimental:validation:Enum=RequestHeaderModifier;RequestMirror;RequestRedirect;URLRewrite;ExtensionRef>
@@ -741,6 +778,13 @@ type HTTPPathModifier struct {
741778
// Type defines the type of path modifier. Additional types may be
742779
// added in a future release of the API.
743780
//
781+
// Note that values may be added to this enum, implementations
782+
// must ensure that unknown values will not cause a crash.
783+
//
784+
// Unknown values here must result in the implementation setting the
785+
// Attached Condition for the Route to `status: False`, with a
786+
// Reason of `UnsupportedValue`.
787+
//
744788
// <gateway:experimental>
745789
// +kubebuilder:validation:Enum=ReplaceFullPath;ReplacePrefixMatch
746790
Type HTTPPathModifierType `json:"type"`
@@ -778,6 +822,13 @@ type HTTPRequestRedirectFilter struct {
778822
//
779823
// Support: Extended
780824
//
825+
// Note that values may be added to this enum, implementations
826+
// must ensure that unknown values will not cause a crash.
827+
//
828+
// Unknown values here must result in the implementation setting the
829+
// Attached Condition for the Route to `status: False`, with a
830+
// Reason of `UnsupportedValue`.
831+
//
781832
// +optional
782833
// +kubebuilder:validation:Enum=http;https
783834
Scheme *string `json:"scheme,omitempty"`
@@ -814,6 +865,13 @@ type HTTPRequestRedirectFilter struct {
814865
//
815866
// Support: Core
816867
//
868+
// Note that values may be added to this enum, implementations
869+
// must ensure that unknown values will not cause a crash.
870+
//
871+
// Unknown values here must result in the implementation setting the
872+
// Attached Condition for the Route to `status: False`, with a
873+
// Reason of `UnsupportedValue`.
874+
//
817875
// +optional
818876
// +kubebuilder:default=302
819877
// +kubebuilder:validation:Enum=301;302

apis/v1beta1/shared_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ const (
217217
// compatible Listeners whose Hostname matches the route
218218
RouteReasonNoMatchingListenerHostname RouteConditionReason = "NoMatchingListenerHostname"
219219

220+
// This reason is used with the "Accepted" condition when a value for an Enum
221+
// is not recognized.
222+
RouteReasonUnsupportedValue RouteConditionReason = "UnsupportedValue"
223+
220224
// This condition indicates whether the controller was able to resolve all
221225
// the object references for the Route.
222226
//

0 commit comments

Comments
 (0)