Skip to content

Commit a716675

Browse files
committed
Fix OpenAPI validations by adding API list markers
1 parent 08b0c9b commit a716675

30 files changed

+409
-11
lines changed

apis/v1/gateway_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ type GatewaySpec struct {
260260
// Support: Extended
261261
//
262262
// +optional
263+
// +listType=atomic
263264
// <gateway:validateIPAddress>
264265
// +kubebuilder:validation:MaxItems=16
265266
// +kubebuilder:validation:XValidation:message="IPAddress values must be unique",rule="self.all(a1, a1.type == 'IPAddress' ? self.exists_one(a2, a2.type == a1.type && a2.value == a1.value) : true )"
@@ -561,6 +562,7 @@ type GatewayTLSConfig struct {
561562
// Support: Implementation-specific (More than one reference or other resource types)
562563
//
563564
// +optional
565+
// +listType=atomic
564566
// +kubebuilder:validation:MaxItems=64
565567
CertificateRefs []SecretObjectReference `json:"certificateRefs,omitempty"`
566568

@@ -635,6 +637,7 @@ type FrontendTLSValidation struct {
635637
// "ResolvedRefs" condition MUST be set to False for this listener with the
636638
// "RefNotPermitted" reason.
637639
//
640+
// +listType=atomic
638641
// +kubebuilder:validation:MaxItems=8
639642
// +kubebuilder:validation:MinItems=1
640643
CACertificateRefs []ObjectReference `json:"caCertificateRefs,omitempty"`
@@ -648,6 +651,7 @@ type AllowedRoutes struct {
648651
// Support: Core
649652
//
650653
// +optional
654+
// +listType=atomic
651655
// +kubebuilder:default={from: Same}
652656
Namespaces *RouteNamespaces `json:"namespaces,omitempty"`
653657

@@ -664,6 +668,7 @@ type AllowedRoutes struct {
664668
// Support: Core
665669
//
666670
// +optional
671+
// +listType=atomic
667672
// +kubebuilder:validation:MaxItems=8
668673
Kinds []RouteGroupKind `json:"kinds,omitempty"`
669674
}
@@ -780,6 +785,7 @@ type GatewayStatus struct {
780785
// * a specified address was unusable (e.g. already in use)
781786
//
782787
// +optional
788+
// +listType=atomic
783789
// <gateway:validateIPAddress>
784790
// +kubebuilder:validation:MaxItems=16
785791
Addresses []GatewayStatusAddress `json:"addresses,omitempty"`
@@ -1108,6 +1114,7 @@ type ListenerStatus struct {
11081114
// and invalid Route kinds are specified, the implementation MUST
11091115
// reference the valid Route kinds that have been specified.
11101116
//
1117+
// +listType=atomic
11111118
// +kubebuilder:validation:MaxItems=8
11121119
SupportedKinds []RouteGroupKind `json:"supportedKinds"`
11131120

apis/v1/grpcroute_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,14 @@ type GRPCRouteSpec struct {
137137
// Support: Core
138138
//
139139
// +optional
140+
// +listType=set
140141
// +kubebuilder:validation:MaxItems=16
141142
Hostnames []Hostname `json:"hostnames,omitempty"`
142143

143144
// Rules are a list of GRPC matchers, filters and actions.
144145
//
145146
// +optional
147+
// +listType=atomic
146148
// +kubebuilder:validation:MaxItems=16
147149
// +kubebuilder:validation:XValidation:message="While 16 rules and 64 matches per rule are allowed, the total number of matches across all rules in a route must be less than 128",rule="(self.size() > 0 ? (has(self[0].matches) ? self[0].matches.size() : 0) : 0) + (self.size() > 1 ? (has(self[1].matches) ? self[1].matches.size() : 0) : 0) + (self.size() > 2 ? (has(self[2].matches) ? self[2].matches.size() : 0) : 0) + (self.size() > 3 ? (has(self[3].matches) ? self[3].matches.size() : 0) : 0) + (self.size() > 4 ? (has(self[4].matches) ? self[4].matches.size() : 0) : 0) + (self.size() > 5 ? (has(self[5].matches) ? self[5].matches.size() : 0) : 0) + (self.size() > 6 ? (has(self[6].matches) ? self[6].matches.size() : 0) : 0) + (self.size() > 7 ? (has(self[7].matches) ? self[7].matches.size() : 0) : 0) + (self.size() > 8 ? (has(self[8].matches) ? self[8].matches.size() : 0) : 0) + (self.size() > 9 ? (has(self[9].matches) ? self[9].matches.size() : 0) : 0) + (self.size() > 10 ? (has(self[10].matches) ? self[10].matches.size() : 0) : 0) + (self.size() > 11 ? (has(self[11].matches) ? self[11].matches.size() : 0) : 0) + (self.size() > 12 ? (has(self[12].matches) ? self[12].matches.size() : 0) : 0) + (self.size() > 13 ? (has(self[13].matches) ? self[13].matches.size() : 0) : 0) + (self.size() > 14 ? (has(self[14].matches) ? self[14].matches.size() : 0) : 0) + (self.size() > 15 ? (has(self[15].matches) ? self[15].matches.size() : 0) : 0) <= 128"
148150
// <gateway:experimental:validation:XValidation:message="Rule name must be unique within the route",rule="self.all(l1, !has(l1.name) || self.exists_one(l2, has(l2.name) && l1.name == l2.name))">
@@ -210,6 +212,7 @@ type GRPCRouteRule struct {
210212
// the above criteria.
211213
//
212214
// +optional
215+
// +listType=atomic
213216
// +kubebuilder:validation:MaxItems=64
214217
Matches []GRPCRouteMatch `json:"matches,omitempty"`
215218

@@ -239,6 +242,7 @@ type GRPCRouteRule struct {
239242
// Support: Core
240243
//
241244
// +optional
245+
// +listType=atomic
242246
// +kubebuilder:validation:MaxItems=16
243247
// +kubebuilder:validation:XValidation:message="RequestHeaderModifier filter cannot be repeated",rule="self.filter(f, f.type == 'RequestHeaderModifier').size() <= 1"
244248
// +kubebuilder:validation:XValidation:message="ResponseHeaderModifier filter cannot be repeated",rule="self.filter(f, f.type == 'ResponseHeaderModifier').size() <= 1"
@@ -274,6 +278,7 @@ type GRPCRouteRule struct {
274278
// Support for weight: Core
275279
//
276280
// +optional
281+
// +listType=atomic
277282
// +kubebuilder:validation:MaxItems=16
278283
BackendRefs []GRPCBackendRef `json:"backendRefs,omitempty"`
279284

@@ -631,6 +636,7 @@ type GRPCBackendRef struct {
631636
// Filters field in GRPCRouteRule.)
632637
//
633638
// +optional
639+
// +listType=atomic
634640
// +kubebuilder:validation:MaxItems=16
635641
// +kubebuilder:validation:XValidation:message="RequestHeaderModifier filter cannot be repeated",rule="self.filter(f, f.type == 'RequestHeaderModifier').size() <= 1"
636642
// +kubebuilder:validation:XValidation:message="ResponseHeaderModifier filter cannot be repeated",rule="self.filter(f, f.type == 'ResponseHeaderModifier').size() <= 1"

apis/v1/httproute_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,14 @@ type HTTPRouteSpec struct {
111111
// Support: Core
112112
//
113113
// +optional
114+
// +listType=set
114115
// +kubebuilder:validation:MaxItems=16
115116
Hostnames []Hostname `json:"hostnames,omitempty"`
116117

117118
// Rules are a list of HTTP matchers, filters and actions.
118119
//
119120
// +optional
121+
// +listType=atomic
120122
// <gateway:experimental:validation:XValidation:message="Rule name must be unique within the route",rule="self.all(l1, !has(l1.name) || self.exists_one(l2, has(l2.name) && l1.name == l2.name))">
121123
// +kubebuilder:validation:MaxItems=16
122124
// +kubebuilder:default={{matches: {{path: {type: "PathPrefix", value: "/"}}}}}
@@ -198,6 +200,7 @@ type HTTPRouteRule struct {
198200
// parent a request is coming from, a HTTP 404 status code MUST be returned.
199201
//
200202
// +optional
203+
// +listType=atomic
201204
// +kubebuilder:validation:MaxItems=64
202205
// +kubebuilder:default={{path:{ type: "PathPrefix", value: "/"}}}
203206
Matches []HTTPRouteMatch `json:"matches,omitempty"`
@@ -240,6 +243,7 @@ type HTTPRouteRule struct {
240243
// Support: Core
241244
//
242245
// +optional
246+
// +listType=atomic
243247
// +kubebuilder:validation:MaxItems=16
244248
// +kubebuilder:validation:XValidation:message="May specify either httpRouteFilterRequestRedirect or httpRouteFilterRequestRewrite, but not both",rule="!(self.exists(f, f.type == 'RequestRedirect') && self.exists(f, f.type == 'URLRewrite'))"
245249
// +kubebuilder:validation:XValidation:message="RequestHeaderModifier filter cannot be repeated",rule="self.filter(f, f.type == 'RequestHeaderModifier').size() <= 1"
@@ -285,6 +289,7 @@ type HTTPRouteRule struct {
285289
// Support for weight: Core
286290
//
287291
// +optional
292+
// +listType=atomic
288293
// +kubebuilder:validation:MaxItems=16
289294
BackendRefs []HTTPBackendRef `json:"backendRefs,omitempty"`
290295

@@ -379,6 +384,7 @@ type HTTPRouteRetry struct {
379384
// Support: Extended
380385
//
381386
// +optional
387+
// +listType=set
382388
Codes []HTTPRouteRetryStatusCode `json:"codes,omitempty"`
383389

384390
// Attempts specifies the maximum number of times an individual request
@@ -1588,6 +1594,7 @@ type HTTPBackendRef struct {
15881594
// Filters field in HTTPRouteRule.)
15891595
//
15901596
// +optional
1597+
// +listType=atomic
15911598
// +kubebuilder:validation:MaxItems=16
15921599
// +kubebuilder:validation:XValidation:message="May specify either httpRouteFilterRequestRedirect or httpRouteFilterRequestRewrite, but not both",rule="!(self.exists(f, f.type == 'RequestRedirect') && self.exists(f, f.type == 'URLRewrite'))"
15931600
// +kubebuilder:validation:XValidation:message="RequestHeaderModifier filter cannot be repeated",rule="self.filter(f, f.type == 'RequestHeaderModifier').size() <= 1"

apis/v1/shared_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ type CommonRouteSpec struct {
218218
// </gateway:experimental:description>
219219
//
220220
// +optional
221+
// +listType=atomic
221222
// +kubebuilder:validation:MaxItems=32
222223
// <gateway:standard:validation:XValidation:message="sectionName must be specified when parentRefs includes 2 or more references to the same parent",rule="self.all(p1, self.all(p2, p1.group == p2.group && p1.kind == p2.kind && p1.name == p2.name && (((!has(p1.__namespace__) || p1.__namespace__ == '') && (!has(p2.__namespace__) || p2.__namespace__ == '')) || (has(p1.__namespace__) && has(p2.__namespace__) && p1.__namespace__ == p2.__namespace__ )) ? ((!has(p1.sectionName) || p1.sectionName == '') == (!has(p2.sectionName) || p2.sectionName == '')) : true))">
223224
// <gateway:standard:validation:XValidation:message="sectionName must be unique when parentRefs includes 2 or more references to the same parent",rule="self.all(p1, self.exists_one(p2, p1.group == p2.group && p1.kind == p2.kind && p1.name == p2.name && (((!has(p1.__namespace__) || p1.__namespace__ == '') && (!has(p2.__namespace__) || p2.__namespace__ == '')) || (has(p1.__namespace__) && has(p2.__namespace__) && p1.__namespace__ == p2.__namespace__ )) && (((!has(p1.sectionName) || p1.sectionName == '') && (!has(p2.sectionName) || p2.sectionName == '')) || (has(p1.sectionName) && has(p2.sectionName) && p1.sectionName == p2.sectionName))))">
@@ -498,6 +499,7 @@ type RouteStatus struct {
498499
// A maximum of 32 Gateways will be represented in this list. An empty list
499500
// means the route has not been attached to any Gateway.
500501
//
502+
// +listType=atomic
501503
// +kubebuilder:validation:MaxItems=32
502504
Parents []RouteParentStatus `json:"parents"`
503505
}

apis/v1alpha2/policy_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ type PolicyStatus struct {
233233
// additional Gateways would be able to reference the Service targeted by
234234
// the BackendTLSPolicy.
235235
//
236+
// +listType=atomic
236237
// +kubebuilder:validation:MaxItems=16
237238
Ancestors []PolicyAncestorStatus `json:"ancestors"`
238239
}

apis/v1alpha2/tcproute_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type TCPRouteSpec struct {
4747

4848
// Rules are a list of TCP matchers and actions.
4949
//
50+
// +listType=atomic
5051
// +kubebuilder:validation:MinItems=1
5152
// +kubebuilder:validation:MaxItems=16
5253
// <gateway:experimental:validation:XValidation:message="Rule name must be unique within the route",rule="self.all(l1, !has(l1.name) || self.exists_one(l2, has(l2.name) && l1.name == l2.name))">
@@ -81,6 +82,7 @@ type TCPRouteRule struct {
8182
//
8283
// Support for weight: Extended
8384
//
85+
// +listType=atomic
8486
// +kubebuilder:validation:MinItems=1
8587
// +kubebuilder:validation:MaxItems=16
8688
BackendRefs []BackendRef `json:"backendRefs,omitempty"`

apis/v1alpha2/tlsroute_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,13 @@ type TLSRouteSpec struct {
8282
// Support: Core
8383
//
8484
// +optional
85+
// +listType=set
8586
// +kubebuilder:validation:MaxItems=16
8687
Hostnames []Hostname `json:"hostnames,omitempty"`
8788

8889
// Rules are a list of TLS matchers and actions.
8990
//
91+
// +listType=atomic
9092
// +kubebuilder:validation:MinItems=1
9193
// +kubebuilder:validation:MaxItems=16
9294
// <gateway:experimental:validation:XValidation:message="Rule name must be unique within the route",rule="self.all(l1, !has(l1.name) || self.exists_one(l2, has(l2.name) && l1.name == l2.name))">
@@ -124,6 +126,7 @@ type TLSRouteRule struct {
124126
//
125127
// Support for weight: Extended
126128
//
129+
// +listType=atomic
127130
// +kubebuilder:validation:MinItems=1
128131
// +kubebuilder:validation:MaxItems=16
129132
BackendRefs []BackendRef `json:"backendRefs,omitempty"`

apis/v1alpha2/udproute_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type UDPRouteSpec struct {
4747

4848
// Rules are a list of UDP matchers and actions.
4949
//
50+
// +listType=atomic
5051
// +kubebuilder:validation:MinItems=1
5152
// +kubebuilder:validation:MaxItems=16
5253
// <gateway:experimental:validation:XValidation:message="Rule name must be unique within the route",rule="self.all(l1, !has(l1.name) || self.exists_one(l2, has(l2.name) && l1.name == l2.name))">
@@ -81,6 +82,7 @@ type UDPRouteRule struct {
8182
//
8283
// Support for weight: Extended
8384
//
85+
// +listType=atomic
8486
// +kubebuilder:validation:MinItems=1
8587
// +kubebuilder:validation:MaxItems=16
8688
BackendRefs []BackendRef `json:"backendRefs,omitempty"`

apis/v1alpha3/backendtlspolicy_types.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ type BackendTLSPolicySpec struct {
7777
//
7878
// Support: Implementation-specific for any other resource
7979
//
80+
// +listType=atomic
8081
// +kubebuilder:validation:MinItems=1
8182
// +kubebuilder:validation:MaxItems=16
8283
// +kubebuilder:validation:XValidation:message="sectionName must be specified when targetRefs includes 2 or more references to the same target",rule="self.all(p1, self.all(p2, p1.group == p2.group && p1.kind == p2.kind && p1.name == p2.name ? ((!has(p1.sectionName) || p1.sectionName == '') == (!has(p2.sectionName) || p2.sectionName == '')) : true))"
@@ -128,8 +129,9 @@ type BackendTLSPolicyValidation struct {
128129
// Support: Implementation-specific (More than one reference, or other kinds
129130
// of resources).
130131
//
131-
// +kubebuilder:validation:MaxItems=8
132132
// +optional
133+
// +listType=atomic
134+
// +kubebuilder:validation:MaxItems=8
133135
CACertificateRefs []v1.LocalObjectReference `json:"caCertificateRefs,omitempty"`
134136

135137
// WellKnownCACertificates specifies whether system CA certificates may be used in
@@ -145,6 +147,7 @@ type BackendTLSPolicyValidation struct {
145147
// Support: Implementation-specific
146148
//
147149
// +optional
150+
// +listType=atomic
148151
WellKnownCACertificates *WellKnownCACertificatesType `json:"wellKnownCACertificates,omitempty"`
149152

150153
// Hostname is used for two purposes in the connection between Gateways and
@@ -163,6 +166,7 @@ type BackendTLSPolicyValidation struct {
163166
// Support: Extended
164167
//
165168
// +optional
169+
// +listType=atomic
166170
// +kubebuilder:validation:MaxItems=5
167171
SubjectAltNames []SubjectAltName `json:"subjectAltNames,omitempty"`
168172
}

apis/v1alpha3/tlsroute_types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,15 @@ type TLSRouteSpec struct {
8484
//
8585
// Support: Core
8686
//
87+
// +required
88+
// +listType=set
8789
// +kubebuilder:validation:MinItems=1
8890
// +kubebuilder:validation:MaxItems=16
89-
// +required
9091
Hostnames []Hostname `json:"hostnames,omitempty"`
9192

9293
// Rules are a list of TLS matchers and actions.
9394
//
95+
// +listType=atomic
9496
// +kubebuilder:validation:MinItems=1
9597
// +kubebuilder:validation:MaxItems=16
9698
// <gateway:experimental:validation:XValidation:message="Rule name must be unique within the route",rule="self.all(l1, !has(l1.name) || self.exists_one(l2, has(l2.name) && l1.name == l2.name))">

0 commit comments

Comments
 (0)