You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// At least one of Service and Method MUST be a non-empty string.
315
+
//
316
+
// +kubebuilder:validation:XValidation:message="One or both of 'service' or 'method' must be specified",rule="has(self.type) ? has(self.service) || has(self.method) : true"
317
+
// +kubebuilder:validation:XValidation:message="service must only contain valid characters (matching ^(?i)\\.?[a-z_][a-z_0-9]*(\\.[a-z_][a-z_0-9]*)*$)",rule="(!has(self.type) || self.type == 'Exact') && has(self.service) ? self.service.matches(r\"\"\"^(?i)\\.?[a-z_][a-z_0-9]*(\\.[a-z_][a-z_0-9]*)*$\"\"\"): true"
318
+
// +kubebuilder:validation:XValidation:message="method must only contain valid characters (matching ^[A-Za-z_][A-Za-z_0-9]*$)",rule="(!has(self.type) || self.type == 'Exact') && has(self.method) ? self.method.matches(r\"\"\"^[A-Za-z_][A-Za-z_0-9]*$\"\"\"): true"
316
319
typeGRPCMethodMatchstruct {
317
320
// Type specifies how to match against the service and/or method.
318
321
// Support: Core (Exact with service and method specified)
name: "valid GRPCRoute with 1 service in GRPCMethodMatch field",
313
+
method: gatewayv1a2.GRPCMethodMatch{
314
+
Service: &service,
315
+
},
316
+
},
317
+
{
318
+
name: "valid GRPCRoute with 1 method in GRPCMethodMatch field",
319
+
method: gatewayv1a2.GRPCMethodMatch{
320
+
Method: &method,
321
+
},
322
+
},
323
+
{
324
+
name: "invalid GRPCRoute missing service or method in GRPCMethodMatch field",
325
+
method: gatewayv1a2.GRPCMethodMatch{
326
+
Service: nil,
327
+
Method: nil,
328
+
},
329
+
wantErrors: []string{"One or both of 'service' or 'method"},
330
+
},
331
+
{
332
+
name: "GRPCRoute use regex in service and method with undefined match type",
333
+
method: gatewayv1a2.GRPCMethodMatch{
334
+
Service: ®ex,
335
+
Method: ®ex,
336
+
},
337
+
wantErrors: []string{"service must only contain valid characters (matching ^(?i)\\.?[a-z_][a-z_0-9]*(\\.[a-z_][a-z_0-9]*)*$)", "method must only contain valid characters (matching ^[A-Za-z_][A-Za-z_0-9]*$)"},
338
+
},
339
+
{
340
+
name: "GRPCRoute use regex in service and method with match type Exact",
341
+
method: gatewayv1a2.GRPCMethodMatch{
342
+
Type: ptrTo(gatewayv1a2.GRPCMethodMatchExact),
343
+
Service: ®ex,
344
+
Method: ®ex,
345
+
},
346
+
wantErrors: []string{"service must only contain valid characters (matching ^(?i)\\.?[a-z_][a-z_0-9]*(\\.[a-z_][a-z_0-9]*)*$)", "method must only contain valid characters (matching ^[A-Za-z_][A-Za-z_0-9]*$)"},
347
+
},
348
+
{
349
+
name: "GRPCRoute use regex in method with undefined match type",
350
+
method: gatewayv1a2.GRPCMethodMatch{
351
+
Method: ®ex,
352
+
},
353
+
wantErrors: []string{"method must only contain valid characters (matching ^[A-Za-z_][A-Za-z_0-9]*$)"},
354
+
},
355
+
{
356
+
name: "GRPCRoute use regex in service with match type Exact",
357
+
method: gatewayv1a2.GRPCMethodMatch{
358
+
Type: ptrTo(gatewayv1a2.GRPCMethodMatchExact),
359
+
Service: ®ex,
360
+
},
361
+
wantErrors: []string{"service must only contain valid characters (matching ^(?i)\\.?[a-z_][a-z_0-9]*(\\.[a-z_][a-z_0-9]*)*$)"},
362
+
},
363
+
{
364
+
name: "GRPCRoute use regex in service and method with match type RegularExpression",
0 commit comments